@kitman-sh/sdk 0.9.0 → 0.10.53
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/build/index.js +531 -116
- package/dist/{chunk-36jhc745.js → chunk-tcbgb4wm.js} +1841 -1574
- package/dist/{chunk-e1tqypyy.js → chunk-zvzw3zs4.js} +824 -419
- package/dist/loop/index.js +117 -3
- package/dist/program/index.js +8 -4
- package/package.json +6 -6
- package/types/packages/core/src/agent-capabilities.d.ts +6 -0
- package/types/packages/core/src/agent-environment.d.ts +32 -216
- package/types/packages/core/src/agent-sandbox-policy.d.ts +17 -3
- package/types/packages/core/src/change-request-review.d.ts +20 -5
- package/types/packages/core/src/change-request.d.ts +33 -208
- package/types/packages/core/src/crypto.d.ts +2 -0
- package/types/packages/core/src/index.d.ts +8 -4
- package/types/packages/core/src/{package-declarations.d.ts → kit-declarations.d.ts} +84 -180
- package/types/packages/core/src/kit-install.d.ts +130 -0
- package/types/packages/core/src/kit-setup.d.ts +316 -0
- package/types/packages/core/src/kit.d.ts +302 -1444
- package/types/packages/core/src/loop-layers.d.ts +33 -4
- package/types/packages/core/src/loop.d.ts +325 -55
- package/types/packages/core/src/marketplace.d.ts +51 -10
- package/types/packages/core/src/my-teams.d.ts +135 -20
- package/types/packages/core/src/network-host.d.ts +41 -0
- package/types/packages/core/src/notification.d.ts +8 -0
- package/types/packages/core/src/npm-registry.d.ts +65 -0
- package/types/packages/core/src/proposal.d.ts +0 -76
- package/types/packages/core/src/push.d.ts +68 -0
- package/types/packages/core/src/question-recommendation.d.ts +28 -0
- package/types/packages/core/src/redaction.d.ts +15 -3
- package/types/packages/core/src/resource-claim.d.ts +79 -0
- package/types/packages/core/src/run-display.d.ts +7 -1
- package/types/packages/core/src/run-graph.d.ts +1 -1
- package/types/packages/core/src/run-launch.d.ts +15 -2
- package/types/packages/core/src/run-queue.d.ts +28 -0
- package/types/packages/core/src/runner-eligibility.d.ts +21 -2
- package/types/packages/core/src/runner.d.ts +46 -15
- package/types/packages/core/src/secret.d.ts +18 -1
- package/types/packages/core/src/step-brief.d.ts +21 -7
- package/types/packages/core/src/sync-kit.d.ts +8 -0
- package/types/packages/core/src/task-detail.d.ts +15 -2
- package/types/packages/core/src/task.d.ts +9 -0
- package/types/packages/core/src/transcript.d.ts +24 -4
- package/types/packages/core/src/trust-panel.d.ts +1 -1
- package/types/packages/core/src/waiting-on.d.ts +14 -0
- package/types/packages/core/src/work-unit.d.ts +339 -8
- package/types/packages/live/src/rpc/runner-client.d.ts +505 -10
- package/types/packages/live/src/rpc/runner-group.d.ts +958 -28
- package/types/packages/sdk/src/build/index.d.ts +45 -9
- package/types/packages/sdk/src/loop/activities.d.ts +382 -2
- package/types/packages/sdk/src/loop/claims.d.ts +57 -0
- package/types/packages/sdk/src/loop/config.d.ts +38 -31
- package/types/packages/sdk/src/loop/continuing.d.ts +22 -0
- package/types/packages/sdk/src/loop/define.d.ts +30 -5
- package/types/packages/sdk/src/loop/evidence.d.ts +18 -3
- package/types/packages/sdk/src/loop/index.d.ts +4 -0
- package/types/packages/sdk/src/loop/measure.d.ts +132 -0
- package/types/packages/sdk/src/loop/plan.d.ts +2 -2
- package/types/packages/sdk/src/loop/steps.d.ts +127 -17
- package/types/packages/sdk/src/loop/sync.d.ts +53 -0
- package/types/packages/sdk/src/loop/test-loop.d.ts +25 -5
- package/types/packages/sdk/src/program/engine.d.ts +95 -3
- package/types/packages/sdk/src/program/host.d.ts +198 -36
- package/types/packages/core/src/engineering-resources.d.ts +0 -24
- package/types/packages/core/src/package.d.ts +0 -369
|
@@ -3,7 +3,9 @@ import * as Context from 'effect/Context';
|
|
|
3
3
|
import * as Duration from 'effect/Duration';
|
|
4
4
|
import * as Effect from 'effect/Effect';
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
|
-
import { DurableDeferred } from 'effect/workflow';
|
|
6
|
+
import { Activity, DurableDeferred } from 'effect/workflow';
|
|
7
|
+
import { type QuestionAdvice, type QuestionOption } from '../../../core/src/question-recommendation';
|
|
8
|
+
import type { MeasurePlan } from '../../../core/src/work-unit';
|
|
7
9
|
import { type EventFilter, type LoopCapability, type LoopDefinition, type LoopSchema } from './define';
|
|
8
10
|
declare const StepFailed_base: Schema.Class<StepFailed, Schema.TaggedStruct<"StepFailed", {
|
|
9
11
|
readonly step: Schema.String;
|
|
@@ -31,6 +33,13 @@ declare const WaitTimedOut_base: Schema.Class<WaitTimedOut, Schema.TaggedStruct<
|
|
|
31
33
|
}>, Cause.YieldableError>;
|
|
32
34
|
export declare class WaitTimedOut extends WaitTimedOut_base {
|
|
33
35
|
}
|
|
36
|
+
declare const ChangeRequestClosed_base: Schema.Class<ChangeRequestClosed, Schema.TaggedStruct<"ChangeRequestClosed", {
|
|
37
|
+
readonly step: Schema.String;
|
|
38
|
+
readonly merged: Schema.Boolean;
|
|
39
|
+
}>, Cause.YieldableError>;
|
|
40
|
+
/** The ChangeRequest a wait was on was closed or merged before the Event it waited for came. */
|
|
41
|
+
export declare class ChangeRequestClosed extends ChangeRequestClosed_base {
|
|
42
|
+
}
|
|
34
43
|
declare const ChildFailed_base: Schema.Class<ChildFailed, Schema.TaggedStruct<"ChildFailed", {
|
|
35
44
|
readonly step: Schema.String;
|
|
36
45
|
readonly loop: Schema.String;
|
|
@@ -41,7 +50,7 @@ export declare class ChildFailed extends ChildFailed_base {
|
|
|
41
50
|
}
|
|
42
51
|
declare const CapabilityDenied_base: Schema.Class<CapabilityDenied, Schema.TaggedStruct<"CapabilityDenied", {
|
|
43
52
|
readonly step: Schema.String;
|
|
44
|
-
readonly capability: Schema.Literals<readonly ["agent_work", "ask", "call", "verify", "change_request", "write_back", "post_comment", "create_tasks", "merge_change_request", "publish_release", "read_transcripts", "propose", "read_project", "draft_update"]>;
|
|
53
|
+
readonly capability: Schema.Literals<readonly ["agent_work", "ask", "call", "verify", "change_request", "write_back", "post_comment", "create_tasks", "merge_change_request", "approve_change_request", "publish_release", "read_transcripts", "read_change_request", "measure", "claim", "propose", "read_project", "draft_update"]>;
|
|
45
54
|
/** A Secret the Step names that its Loop does not declare. */
|
|
46
55
|
readonly secret: Schema.optionalKey<Schema.String>;
|
|
47
56
|
}>, Cause.YieldableError>;
|
|
@@ -64,7 +73,7 @@ export declare const LoopEvent: Schema.Struct<{
|
|
|
64
73
|
readonly payload: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
65
74
|
}>;
|
|
66
75
|
export type LoopEvent = typeof LoopEvent.Type;
|
|
67
|
-
export type StepKind = 'agent_work' | 'ask' | 'call' | 'wait_for' | 'verify' | 'change_request' | 'write_back' | 'artifact' | 'file' | 'note' | 'comment' | 'create_tasks' | 'integration_branch' | 'merge_change_request' | 'release' | 'transcripts' | 'propose' | 'project_activity' | 'draft_update';
|
|
76
|
+
export type StepKind = 'agent_work' | 'ask' | 'call' | 'wait_for' | 'verify' | 'change_request' | 'write_back' | 'artifact' | 'file' | 'note' | 'comment' | 'create_tasks' | 'integration_branch' | 'merge_change_request' | 'approve_change_request' | 'close_change_request' | 'rerun_pipeline' | 'report_pipeline' | 'release' | 'transcripts' | 'propose' | 'project_activity' | 'draft_update' | 'pipeline_status' | 'review_threads' | 'open_change_requests' | 'own_change_requests' | 'measure' | 'claim' | 'let_go';
|
|
68
77
|
/** A Step a Run took, as its program saw it. */
|
|
69
78
|
export type StepRecord = {
|
|
70
79
|
readonly name: string;
|
|
@@ -96,23 +105,34 @@ type Launch = {
|
|
|
96
105
|
readonly token: DurableDeferred.Token;
|
|
97
106
|
};
|
|
98
107
|
export type AgentWorkLaunch = Launch & {
|
|
108
|
+
/** The journal name its Output resolves; a base sync's starts with `sync/`. */
|
|
109
|
+
readonly deferredName: string;
|
|
99
110
|
readonly role: string;
|
|
100
111
|
readonly agent: string;
|
|
101
112
|
readonly prompt: string;
|
|
113
|
+
/** The skill the Step runs, whose body Kitman puts ahead of the prompt. */
|
|
114
|
+
readonly skill?: string;
|
|
102
115
|
/** JSON Schema the Output must match. */
|
|
103
116
|
readonly output: Schema.Json;
|
|
104
117
|
/** Secrets for the agent's sandbox environment. */
|
|
105
118
|
readonly secrets?: readonly string[];
|
|
119
|
+
/** The Step's time budget across its attempts. */
|
|
120
|
+
readonly timeoutMillis?: number;
|
|
121
|
+
/** The branch whose head the Runner merges into the checkout before the agent starts. */
|
|
122
|
+
readonly mergeTarget?: string;
|
|
106
123
|
};
|
|
107
|
-
/** A verification a human may approve for the repository;
|
|
124
|
+
/** A verification a human may approve for the repository; only `verify`'s `suggested` runs it before they do. */
|
|
108
125
|
export type SuggestedVerification = {
|
|
109
126
|
readonly name: string;
|
|
110
127
|
readonly command: string;
|
|
111
128
|
readonly workingDirectory?: string;
|
|
112
129
|
};
|
|
113
|
-
export type QuestionLaunch = Launch & {
|
|
130
|
+
export type QuestionLaunch = Launch & QuestionAdvice & {
|
|
114
131
|
readonly prompt: string;
|
|
115
132
|
readonly options?: readonly string[];
|
|
133
|
+
/** Taken when the Run is unattended, or when nobody answers within `timeoutMillis`. */
|
|
134
|
+
readonly default?: string;
|
|
135
|
+
readonly timeoutMillis?: number;
|
|
116
136
|
/** Approving the Question approves this verification. */
|
|
117
137
|
readonly verification?: SuggestedVerification;
|
|
118
138
|
};
|
|
@@ -121,15 +141,37 @@ export type VerificationLaunch = Launch & {
|
|
|
121
141
|
readonly revision?: string;
|
|
122
142
|
/** Approved verifications by name; all of them when left out. */
|
|
123
143
|
readonly checks?: readonly string[];
|
|
144
|
+
/** Run in place of approved checks when the repository has none approved, labelled as suggested. */
|
|
145
|
+
readonly suggested?: readonly SuggestedVerification[];
|
|
146
|
+
/** Benchmarks the revision against `base` (the Run's base branch head when left out) in place of checks. */
|
|
147
|
+
readonly measure?: MeasureLaunch;
|
|
148
|
+
};
|
|
149
|
+
export type MeasureLaunch = {
|
|
150
|
+
readonly base?: string;
|
|
151
|
+
readonly plan: MeasurePlan;
|
|
152
|
+
readonly samples: number;
|
|
153
|
+
readonly calibrate: boolean;
|
|
154
|
+
};
|
|
155
|
+
export type ClaimLaunch = Launch & {
|
|
156
|
+
readonly resource: string;
|
|
157
|
+
readonly action: 'claim' | 'take_over' | 'let_go';
|
|
124
158
|
};
|
|
125
159
|
export type ChildLaunch = Launch & {
|
|
126
160
|
readonly loop: string;
|
|
127
161
|
readonly input: Schema.Json;
|
|
128
162
|
};
|
|
163
|
+
/** An Event that settles a wait besides its own, with its own filter and `since`. */
|
|
164
|
+
export type OtherEvent = {
|
|
165
|
+
readonly event: string;
|
|
166
|
+
readonly filter?: EventFilter;
|
|
167
|
+
readonly since?: string;
|
|
168
|
+
};
|
|
129
169
|
export type EventWaitLaunch = Launch & {
|
|
130
170
|
readonly event: string;
|
|
131
171
|
readonly filter?: EventFilter;
|
|
132
172
|
readonly timeoutMillis: number;
|
|
173
|
+
readonly since?: string;
|
|
174
|
+
readonly or?: readonly OtherEvent[];
|
|
133
175
|
};
|
|
134
176
|
declare const LoopHost_base: Context.ServiceClass<LoopHost, "@kitman-sh/sdk/loop/LoopHost", {
|
|
135
177
|
readonly startAgentWork: (launch: AgentWorkLaunch) => Effect.Effect<void, StepFailed>;
|
|
@@ -137,6 +179,7 @@ declare const LoopHost_base: Context.ServiceClass<LoopHost, "@kitman-sh/sdk/loop
|
|
|
137
179
|
readonly admitChild: (launch: ChildLaunch) => Effect.Effect<void, StepFailed>;
|
|
138
180
|
readonly awaitEvent: (launch: EventWaitLaunch) => Effect.Effect<void, StepFailed>;
|
|
139
181
|
readonly startVerification: (launch: VerificationLaunch) => Effect.Effect<void, StepFailed>;
|
|
182
|
+
readonly claimResource: (launch: ClaimLaunch) => Effect.Effect<void, StepFailed>;
|
|
140
183
|
}>;
|
|
141
184
|
/**
|
|
142
185
|
* What Kitman lends a program: each launch hands Kitman a deferred token, and Kitman resolves it with the
|
|
@@ -144,7 +187,11 @@ declare const LoopHost_base: Context.ServiceClass<LoopHost, "@kitman-sh/sdk/loop
|
|
|
144
187
|
*/
|
|
145
188
|
export declare class LoopHost extends LoopHost_base {
|
|
146
189
|
}
|
|
190
|
+
/** The journal entry an agent Step's Output resolves, by its full name. */
|
|
191
|
+
export declare const agentDeferredNamed: (deferredName: string) => DurableDeferred.DurableDeferred<Schema.Codec<Schema.Json, Schema.Json, never, never>, typeof StepFailed>;
|
|
147
192
|
export declare const agentWorkDeferred: (step: string) => DurableDeferred.DurableDeferred<Schema.Codec<Schema.Json, Schema.Json, never, never>, typeof StepFailed>;
|
|
193
|
+
/** A base sync's agent Step, named apart so the host hands it no steers or Corrections meant for the work. */
|
|
194
|
+
export declare const syncDeferred: (step: string) => DurableDeferred.DurableDeferred<Schema.Codec<Schema.Json, Schema.Json, never, never>, typeof StepFailed>;
|
|
148
195
|
export declare const answerDeferred: (step: string) => DurableDeferred.DurableDeferred<Schema.String, typeof StepFailed>;
|
|
149
196
|
export declare const childDeferred: (step: string) => DurableDeferred.DurableDeferred<Schema.Codec<Schema.Json, Schema.Json, never, never>, typeof ChildFailed>;
|
|
150
197
|
export declare const eventDeferred: (step: string) => DurableDeferred.DurableDeferred<Schema.Struct<{
|
|
@@ -155,6 +202,7 @@ export declare const verifyDeferred: (step: string) => DurableDeferred.DurableDe
|
|
|
155
202
|
readonly revision: Schema.String;
|
|
156
203
|
readonly tree: Schema.String;
|
|
157
204
|
readonly passed: Schema.Boolean;
|
|
205
|
+
readonly unchanged: Schema.optionalKey<Schema.Boolean>;
|
|
158
206
|
readonly checks: Schema.$Array<Schema.Struct<{
|
|
159
207
|
readonly name: Schema.String;
|
|
160
208
|
readonly command: Schema.String;
|
|
@@ -162,54 +210,114 @@ export declare const verifyDeferred: (step: string) => DurableDeferred.DurableDe
|
|
|
162
210
|
readonly preExisting: Schema.Boolean;
|
|
163
211
|
readonly durationMs: Schema.Finite;
|
|
164
212
|
readonly evidenceId: Schema.String;
|
|
213
|
+
readonly outputTail: Schema.optionalKey<Schema.String>;
|
|
214
|
+
readonly suggested: Schema.optionalKey<Schema.Boolean>;
|
|
165
215
|
}>>;
|
|
166
216
|
}>, typeof StepFailed>;
|
|
167
217
|
/** Claims the Step name for this Run and checks its capability before running it. */
|
|
168
218
|
export declare const takeStep: <A, E, R>(name: string, kind: StepKind, capability: LoopCapability | undefined, body: Effect.Effect<A, E, R>) => Effect.Effect<A, E | DuplicateStep | CapabilityDenied, R | LoopRun>;
|
|
219
|
+
/** An Activity that only launches; its result arrives through the Step's deferred. */
|
|
220
|
+
export declare const launch: <Success extends Schema.Constraint, Error extends Schema.Constraint>(deferred: DurableDeferred.DurableDeferred<Success, Error>, start: (host: LoopHost['Service'], token: DurableDeferred.Token) => Effect.Effect<void, StepFailed>) => Activity.Activity<Schema.Void, typeof StepFailed, LoopHost>;
|
|
169
221
|
/**
|
|
170
222
|
* An agent does one named Step and submits an Output that decodes against `output`. The named `secrets`, which the
|
|
171
|
-
* Loop must declare, are in its sandbox's environment.
|
|
223
|
+
* Loop must declare, are in its sandbox's environment. With `timeout`, the Step fails once it has run that long, across
|
|
224
|
+
* its attempts, and its agent is stopped. Without one, the Runner stops its agent after 30 minutes. With `skill`, the
|
|
225
|
+
* Step runs that skill of the Run's Kits as a person runs a slash command: its body comes ahead of the prompt.
|
|
172
226
|
*/
|
|
173
|
-
export declare const agentWork: <Out>(name: string, options:
|
|
227
|
+
export declare const agentWork: <Out>(name: string, options: AgentWorkOptions<Out>) => Effect.Effect<Out, CapabilityDenied | DuplicateStep | OutputInvalid | StepFailed, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
228
|
+
type AgentWorkOptions<Out> = {
|
|
174
229
|
readonly agent: string;
|
|
175
230
|
readonly prompt: string;
|
|
231
|
+
readonly skill?: string;
|
|
176
232
|
readonly output: LoopSchema<Out>;
|
|
177
233
|
readonly secrets?: readonly string[];
|
|
234
|
+
readonly timeout?: Duration.Input;
|
|
235
|
+
};
|
|
236
|
+
/** `agentWork` journaled under `deferredOf(name)`, as a base sync is. */
|
|
237
|
+
export declare const agentWorkAs: <Out>(deferredOf: (step: string) => ReturnType<typeof agentDeferredNamed>, name: string, options: AgentWorkOptions<Out> & {
|
|
238
|
+
readonly mergeTarget?: string;
|
|
239
|
+
/** What the agent is asked to submit, when Kitman adds to it before `output` decodes it. */
|
|
240
|
+
readonly answer?: LoopSchema<unknown>;
|
|
178
241
|
}) => Effect.Effect<Out, CapabilityDenied | DuplicateStep | OutputInvalid | StepFailed, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
179
|
-
|
|
242
|
+
/**
|
|
243
|
+
* `agentWork` that, when the Output fails to decode, runs once more as `<name>:again` with why in its brief: a planner
|
|
244
|
+
* whose tickets block each other in a cycle is sent back once with the reason.
|
|
245
|
+
*/
|
|
246
|
+
export declare const agentWorkOnce: <Out>(name: string, options: Parameters<typeof agentWork<Out>>[1]) => Effect.Effect<Out, CapabilityDenied | DuplicateStep | OutputInvalid | StepFailed, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
247
|
+
/**
|
|
248
|
+
* What the Run takes when nobody answers: at once when nobody is attending (a Schedule or an Event started it), else
|
|
249
|
+
* once `timeout` passes, never sooner than a minute. With no `default`, that is the recommended answer when it is safe to
|
|
250
|
+
* store; `null` makes the Question wait for a person, as one that only a person may approve should.
|
|
251
|
+
*/
|
|
252
|
+
type Fallback<Value extends string> = {
|
|
253
|
+
readonly default?: Value | null;
|
|
254
|
+
readonly timeout?: Duration.Input;
|
|
255
|
+
};
|
|
256
|
+
/** The answer the Loop would pick and why, in one or two sentences. */
|
|
257
|
+
type Recommended<Value extends string> = {
|
|
258
|
+
readonly recommended: Value;
|
|
259
|
+
readonly recommendationReason: string;
|
|
260
|
+
};
|
|
261
|
+
type InformationOnly = {
|
|
262
|
+
readonly informationOnly: true;
|
|
263
|
+
readonly recommendationReason: string;
|
|
264
|
+
};
|
|
265
|
+
type OptionValue<Option> = Option extends {
|
|
266
|
+
readonly value: infer Value extends string;
|
|
267
|
+
} ? Value : Option;
|
|
268
|
+
type Question<Options extends readonly QuestionOption[]> = ({
|
|
180
269
|
readonly prompt: string;
|
|
181
270
|
readonly options: Options;
|
|
182
|
-
} | {
|
|
271
|
+
} & Recommended<OptionValue<Options[number]>> & Fallback<OptionValue<Options[number]>>) | ({
|
|
183
272
|
readonly prompt: string;
|
|
184
273
|
readonly freeText: true;
|
|
185
|
-
};
|
|
186
|
-
/**
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
274
|
+
} & (Recommended<string> | InformationOnly) & Fallback<string>);
|
|
275
|
+
/**
|
|
276
|
+
* Puts a Question to a human; an answer outside `options` is refused. Keep the prompt to the context and the decision:
|
|
277
|
+
* an option can carry a short `description` of its trade-off, and every Question recommends an answer and says why.
|
|
278
|
+
*/
|
|
279
|
+
export declare const ask: <const Options extends readonly QuestionOption[]>(name: string, question: Question<Options>) => Effect.Effect<OptionValue<Options[number]>, CapabilityDenied | DuplicateStep | QuestionRefused | StepFailed, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
280
|
+
/** Starts a Child Run of `loop`, a Loop or its id and schemas, and awaits its output. */
|
|
281
|
+
export declare const call: <In, Out>(name: string, loop: Pick<LoopDefinition<In, Out, unknown>, 'id' | 'input' | 'output'>, input: In) => Effect.Effect<Out, CapabilityDenied | ChildFailed | DuplicateStep | StepFailed, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
282
|
+
/**
|
|
283
|
+
* Waits for an Event matching `filter`, which is data the control plane matches. A wait on a ChangeRequest's Event
|
|
284
|
+
* fails with ChangeRequestClosed once that ChangeRequest is closed or merged, rather than waiting out its timeout.
|
|
285
|
+
*/
|
|
191
286
|
export declare const waitFor: (name: string, wait: {
|
|
192
287
|
readonly event: string;
|
|
193
288
|
readonly filter?: EventFilter;
|
|
194
289
|
readonly timeout: Duration.Input;
|
|
290
|
+
/**
|
|
291
|
+
* An ISO time, such as a `pipelineStatus` read's `readAt`: a ChangeRequest state Event received before it does not
|
|
292
|
+
* settle the wait, since the read already superseded it.
|
|
293
|
+
*/
|
|
294
|
+
readonly since?: string;
|
|
295
|
+
/** Other Events that settle the wait too, as a review comment wakes a wait for approval; read the Event's `type`. */
|
|
296
|
+
readonly or?: readonly OtherEvent[];
|
|
195
297
|
}) => Effect.Effect<{
|
|
196
298
|
readonly type: string;
|
|
197
299
|
readonly payload: {
|
|
198
300
|
readonly [x: string]: Schema.Json;
|
|
199
301
|
};
|
|
200
|
-
}, CapabilityDenied | DuplicateStep | StepFailed | WaitTimedOut, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
302
|
+
}, CapabilityDenied | ChangeRequestClosed | DuplicateStep | StepFailed | WaitTimedOut, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
201
303
|
/**
|
|
202
304
|
* Runs the repository's approved verifications at `revision`, or by default at the Run's head (what its Steps last
|
|
203
305
|
* pushed, else its base branch), on an eligible Runner, with no agent. The result is evidence bound to the
|
|
204
|
-
* revision's tree; a failure that is also on the
|
|
306
|
+
* revision's tree; a failure that is also on the baseline is marked pre-existing.
|
|
205
307
|
*/
|
|
206
308
|
export declare const verify: (name: string, request: {
|
|
207
309
|
readonly revision?: string;
|
|
208
310
|
readonly checks?: readonly string[];
|
|
311
|
+
/**
|
|
312
|
+
* Checks to run, labelled as suggested, when the repository has no approved ones, so a repository nobody has set
|
|
313
|
+
* up still gets evidence; ignored once any check is approved.
|
|
314
|
+
*/
|
|
315
|
+
readonly suggested?: readonly SuggestedVerification[];
|
|
209
316
|
}) => Effect.Effect<{
|
|
210
317
|
readonly revision: string;
|
|
211
318
|
readonly tree: string;
|
|
212
319
|
readonly passed: boolean;
|
|
320
|
+
readonly unchanged?: boolean;
|
|
213
321
|
readonly checks: readonly {
|
|
214
322
|
readonly name: string;
|
|
215
323
|
readonly command: string;
|
|
@@ -217,6 +325,8 @@ export declare const verify: (name: string, request: {
|
|
|
217
325
|
readonly preExisting: boolean;
|
|
218
326
|
readonly durationMs: number;
|
|
219
327
|
readonly evidenceId: string;
|
|
328
|
+
readonly outputTail?: string;
|
|
329
|
+
readonly suggested?: boolean;
|
|
220
330
|
}[];
|
|
221
331
|
}, CapabilityDenied | DuplicateStep | StepFailed, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
222
332
|
/** Asks a human to approve a verification, for example one an agent's Output suggested. */
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as Schema from 'effect/Schema';
|
|
2
|
+
/**
|
|
3
|
+
* What a base sync did: nothing to take, a merge that went in, or the files it could not settle. A merge carries the
|
|
4
|
+
* Runner's `catchUp` report of what it did to the branch's own change, when the Runner made one.
|
|
5
|
+
*/
|
|
6
|
+
export declare const BaseSync: Schema.Union<readonly [Schema.Struct<{
|
|
7
|
+
readonly status: Schema.Literal<"up_to_date">;
|
|
8
|
+
}>, Schema.Struct<{
|
|
9
|
+
readonly status: Schema.Literal<"merged">;
|
|
10
|
+
readonly settled: Schema.$Array<Schema.String>;
|
|
11
|
+
readonly catchUp: Schema.optionalKey<Schema.Struct<{
|
|
12
|
+
readonly from: Schema.String;
|
|
13
|
+
readonly head: Schema.String;
|
|
14
|
+
readonly conflicted: Schema.$Array<Schema.String>;
|
|
15
|
+
readonly rewritten: Schema.$Array<Schema.String>;
|
|
16
|
+
readonly changed: Schema.$Array<Schema.String>;
|
|
17
|
+
readonly truncated: Schema.Boolean;
|
|
18
|
+
}>>;
|
|
19
|
+
}>, Schema.Struct<{
|
|
20
|
+
readonly status: Schema.Literal<"conflict">;
|
|
21
|
+
/** The files it could not settle; the merge was aborted, so the branch is as it was. */
|
|
22
|
+
readonly files: Schema.NonEmptyArray<Schema.String>;
|
|
23
|
+
readonly reason: Schema.String;
|
|
24
|
+
}>]>;
|
|
25
|
+
export type BaseSync = typeof BaseSync.Type;
|
|
26
|
+
/**
|
|
27
|
+
* Merges the target branch's head into the Run's branch, so a review sees what will merge and a conflict is met while
|
|
28
|
+
* it is small. The Runner merges outside the agent's sandbox, which cannot write the git directory, and `agent` settles
|
|
29
|
+
* conflicts in one short Step; it is handed no steers or Corrections, which wait for the next Step that works on the
|
|
30
|
+
* change. The Runner commits the merge only on `merged`, so `conflict` comes back with the branch unchanged. `target`
|
|
31
|
+
* is the branch to merge in; the default branch when left out.
|
|
32
|
+
*/
|
|
33
|
+
export declare const syncBase: (name: string, options: {
|
|
34
|
+
readonly agent: string;
|
|
35
|
+
readonly target?: string;
|
|
36
|
+
}) => import("effect/Effect").Effect<{
|
|
37
|
+
readonly status: "up_to_date";
|
|
38
|
+
} | {
|
|
39
|
+
readonly status: "merged";
|
|
40
|
+
readonly settled: readonly string[];
|
|
41
|
+
readonly catchUp?: {
|
|
42
|
+
readonly from: string;
|
|
43
|
+
readonly head: string;
|
|
44
|
+
readonly conflicted: readonly string[];
|
|
45
|
+
readonly rewritten: readonly string[];
|
|
46
|
+
readonly changed: readonly string[];
|
|
47
|
+
readonly truncated: boolean;
|
|
48
|
+
};
|
|
49
|
+
} | {
|
|
50
|
+
readonly status: "conflict";
|
|
51
|
+
readonly files: readonly [string, ...string[]];
|
|
52
|
+
readonly reason: string;
|
|
53
|
+
}, import("./steps").CapabilityDenied | import("./steps").DuplicateStep | import("./steps").OutputInvalid | import("./steps").StepFailed, import("./steps").LoopHost | import("./steps").LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
@@ -2,10 +2,12 @@ import * as Effect from 'effect/Effect';
|
|
|
2
2
|
import * as Exit from 'effect/Exit';
|
|
3
3
|
import * as Schema from 'effect/Schema';
|
|
4
4
|
import { Workflow, WorkflowEngine } from 'effect/workflow';
|
|
5
|
-
import { ArtifactActivity, ChangeRequestActivity, CommentActivity, CreateTasksActivity, FileActivity, IntegrationBranchActivity, MergeChangeRequestActivity, NoteActivity, ProjectActivityActivity, DraftUpdateActivity, ProposeActivity, ReleaseActivity, TranscriptsActivity, WriteBackActivity } from './activities';
|
|
6
|
-
import type
|
|
5
|
+
import { ArtifactActivity, ChangeRequestActivity, CommentActivity, AlertTaskActivity, CreateTasksActivity, FileActivity, IntegrationBranchActivity, MergeChangeRequestActivity, NoteActivity, ProjectActivityActivity, DraftUpdateActivity, ProposeActivity, ReleaseActivity, TranscriptsActivity, ChangeRequestReadActivity, WriteBackActivity } from './activities';
|
|
6
|
+
import { type LoopCapability, type LoopDefinition } from './define';
|
|
7
|
+
import type { MeasureEvidence } from '../../../core/src/work-unit';
|
|
7
8
|
import type { VerifyResult } from './evidence';
|
|
8
|
-
import {
|
|
9
|
+
import { type ClaimResult } from './claims';
|
|
10
|
+
import { InputInvalid, LoopHost, LoopRun, type EventWaitLaunch, type LoopEvent, type StepRecord } from './steps';
|
|
9
11
|
/** Activity and deferred results, encoded as JSON; replaying from it runs no Activity again. */
|
|
10
12
|
export declare const LoopJournal: Schema.Struct<{
|
|
11
13
|
readonly activities: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
@@ -30,10 +32,12 @@ export type HostActivities = {
|
|
|
30
32
|
readonly note: NoteActivity['Service'];
|
|
31
33
|
readonly comment: CommentActivity['Service'];
|
|
32
34
|
readonly createTasks: CreateTasksActivity['Service'];
|
|
35
|
+
readonly alertTask: AlertTaskActivity['Service'];
|
|
33
36
|
readonly integrationBranch: IntegrationBranchActivity['Service'];
|
|
34
37
|
readonly mergeChangeRequest: MergeChangeRequestActivity['Service'];
|
|
35
38
|
readonly release: ReleaseActivity['Service'];
|
|
36
39
|
readonly transcripts: TranscriptsActivity['Service'];
|
|
40
|
+
readonly changeRequestRead: ChangeRequestReadActivity['Service'];
|
|
37
41
|
readonly propose: ProposeActivity['Service'];
|
|
38
42
|
readonly projectActivity: ProjectActivityActivity['Service'];
|
|
39
43
|
readonly draftUpdate: DraftUpdateActivity['Service'];
|
|
@@ -55,13 +59,24 @@ export type TestLoopScript = {
|
|
|
55
59
|
readonly events?: {
|
|
56
60
|
readonly [step: string]: LoopEvent;
|
|
57
61
|
};
|
|
58
|
-
/** Verification results by Step name; a verify left out passes with
|
|
62
|
+
/** Verification results by Step name; a verify left out passes with the suggested checks it was given, if any. */
|
|
59
63
|
readonly verifications?: {
|
|
60
64
|
readonly [step: string]: VerifyResult | ScriptedFailure;
|
|
61
65
|
};
|
|
66
|
+
/** Samples by `measure` Step name; a measure left out measures base and head the same. */
|
|
67
|
+
readonly measurements?: {
|
|
68
|
+
readonly [step: string]: MeasureEvidence | ScriptedFailure;
|
|
69
|
+
};
|
|
70
|
+
/** What each `claim` Step came to; a claim left out is granted. */
|
|
71
|
+
readonly claims?: {
|
|
72
|
+
readonly [step: string]: ClaimResult;
|
|
73
|
+
};
|
|
62
74
|
/** What the control plane grants; the declared capabilities by default. */
|
|
63
75
|
readonly grant?: readonly LoopCapability[];
|
|
64
|
-
|
|
76
|
+
/** Replaces the default host Activities method by method; a method left out keeps its default. */
|
|
77
|
+
readonly activities?: {
|
|
78
|
+
readonly [K in keyof HostActivities]?: Partial<HostActivities[K]>;
|
|
79
|
+
};
|
|
65
80
|
readonly journal?: LoopJournal;
|
|
66
81
|
/** Secret values the program reads with `Config`; none by default. */
|
|
67
82
|
readonly secrets?: {
|
|
@@ -82,12 +97,17 @@ export type TestLoopResult<Out, E> = {
|
|
|
82
97
|
readonly agentLaunches: readonly AgentLaunchRecord[];
|
|
83
98
|
/** Child Runs admitted, with their Input as JSON, in admission order. */
|
|
84
99
|
readonly childLaunches: readonly ChildLaunchRecord[];
|
|
100
|
+
/** Every `waitFor` started, in order. */
|
|
101
|
+
readonly waits: readonly WaitRecord[];
|
|
85
102
|
};
|
|
103
|
+
type WaitRecord = Pick<EventWaitLaunch, 'step' | 'event' | 'filter' | 'since' | 'or'>;
|
|
86
104
|
type AgentLaunchRecord = {
|
|
87
105
|
readonly step: string;
|
|
88
106
|
readonly agent: string;
|
|
89
107
|
readonly prompt: string;
|
|
108
|
+
readonly skill?: string;
|
|
90
109
|
readonly secrets?: readonly string[];
|
|
110
|
+
readonly mergeTarget?: string;
|
|
91
111
|
};
|
|
92
112
|
type ChildLaunchRecord = {
|
|
93
113
|
readonly step: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type OrchestrationWorkUnit, type ProgramWorkUnit, type RunFilePartUrl, type RunFileRecord, type RunFileUpload } from '../../../core/src/index';
|
|
2
|
-
import { type
|
|
2
|
+
import { type QuestionAdvice } from '../../../core/src/question-recommendation';
|
|
3
|
+
import { StepFailed, type MeasureLaunch, type ChangeRequestResult, type EventFilter, type OtherEvent, type IntegrationBranch, type LoopDefinition, type MergeResult, type ReleaseResult, type PlanTicket, type ProposeRequest, type TranscriptsResult, type AlertTaskResult, type PipelineStatus, type ReportPipelineResult, type ReviewThreads, type OpenChangeRequests, type OwnChangeRequests, type DraftUpdateRequest, type ProjectActivityResult, type WriteBackMilestones, type SuggestedVerification } from '../loop';
|
|
3
4
|
import * as Cause from 'effect/Cause';
|
|
4
5
|
import * as Effect from 'effect/Effect';
|
|
5
6
|
import * as FileSystem from 'effect/FileSystem';
|
|
@@ -35,11 +36,13 @@ export type ProgramJournal = {
|
|
|
35
36
|
};
|
|
36
37
|
/** The domain calls a program's Loop makes under its orchestration lease. */
|
|
37
38
|
export type ProgramCapabilities = {
|
|
38
|
-
readonly putQuestion: (question: {
|
|
39
|
+
readonly putQuestion: (question: QuestionAdvice & {
|
|
39
40
|
readonly step: string;
|
|
40
41
|
readonly prompt: string;
|
|
41
42
|
readonly options?: readonly string[];
|
|
42
43
|
readonly verification?: SuggestedVerification;
|
|
44
|
+
readonly default?: string;
|
|
45
|
+
readonly timeoutMillis?: number;
|
|
43
46
|
readonly deferredName: string;
|
|
44
47
|
}) => Effect.Effect<{
|
|
45
48
|
readonly questionId: string;
|
|
@@ -49,6 +52,8 @@ export type ProgramCapabilities = {
|
|
|
49
52
|
readonly deferredName: string;
|
|
50
53
|
readonly revision?: string;
|
|
51
54
|
readonly checks?: readonly string[];
|
|
55
|
+
readonly suggested?: readonly SuggestedVerification[];
|
|
56
|
+
readonly measure?: MeasureLaunch;
|
|
52
57
|
}) => Effect.Effect<{
|
|
53
58
|
readonly verificationId: string;
|
|
54
59
|
}, Error>;
|
|
@@ -58,8 +63,11 @@ export type ProgramCapabilities = {
|
|
|
58
63
|
readonly role: string;
|
|
59
64
|
readonly agentId: string;
|
|
60
65
|
readonly prompt: string;
|
|
66
|
+
readonly skill?: string;
|
|
61
67
|
readonly outputSchema: Schema.Json;
|
|
62
68
|
readonly secrets?: readonly string[];
|
|
69
|
+
readonly timeoutMillis?: number;
|
|
70
|
+
readonly mergeTarget?: string;
|
|
63
71
|
}) => Effect.Effect<{
|
|
64
72
|
readonly stepAttemptId: string;
|
|
65
73
|
}, Error>;
|
|
@@ -69,6 +77,14 @@ export type ProgramCapabilities = {
|
|
|
69
77
|
readonly event: string;
|
|
70
78
|
readonly filter?: EventFilter;
|
|
71
79
|
readonly timeoutMillis: number;
|
|
80
|
+
readonly since?: string;
|
|
81
|
+
readonly or?: readonly OtherEvent[];
|
|
82
|
+
}) => Effect.Effect<void, Error>;
|
|
83
|
+
readonly claimResource: (claim: {
|
|
84
|
+
readonly step: string;
|
|
85
|
+
readonly deferredName: string;
|
|
86
|
+
readonly resource: string;
|
|
87
|
+
readonly action: 'claim' | 'take_over' | 'let_go';
|
|
72
88
|
}) => Effect.Effect<void, Error>;
|
|
73
89
|
readonly admitChild: (child: {
|
|
74
90
|
readonly step: string;
|
|
@@ -121,6 +137,13 @@ export type ProgramCapabilities = {
|
|
|
121
137
|
readonly kind: 'post_comment';
|
|
122
138
|
readonly changeRequestId: string;
|
|
123
139
|
readonly body: string;
|
|
140
|
+
readonly threadId?: string;
|
|
141
|
+
readonly summary?: string;
|
|
142
|
+
readonly anchors?: readonly {
|
|
143
|
+
readonly file: string;
|
|
144
|
+
readonly line: number;
|
|
145
|
+
readonly body: string;
|
|
146
|
+
}[];
|
|
124
147
|
} | {
|
|
125
148
|
readonly kind: 'change_request';
|
|
126
149
|
readonly title: string;
|
|
@@ -132,20 +155,49 @@ export type ProgramCapabilities = {
|
|
|
132
155
|
readonly changeRequestUrl?: string;
|
|
133
156
|
};
|
|
134
157
|
}) => Effect.Effect<ChangeRequestResult | undefined, Error>;
|
|
135
|
-
readonly createPlanTasks: (tickets: readonly PlanTicket[]) => Effect.Effect<readonly {
|
|
158
|
+
readonly createPlanTasks: (tickets: readonly PlanTicket[], projectId?: string) => Effect.Effect<readonly {
|
|
136
159
|
readonly key: string;
|
|
137
160
|
readonly taskId: string;
|
|
138
161
|
}[], Error>;
|
|
162
|
+
readonly alertTask: (request: {
|
|
163
|
+
readonly step: string;
|
|
164
|
+
readonly fingerprint: string;
|
|
165
|
+
readonly title: string;
|
|
166
|
+
readonly windowHours: number;
|
|
167
|
+
readonly resolved?: boolean;
|
|
168
|
+
readonly priority?: 'urgent' | 'high' | 'medium' | 'low';
|
|
169
|
+
}) => Effect.Effect<AlertTaskResult, Error>;
|
|
139
170
|
readonly readTranscripts: (request: {
|
|
140
171
|
readonly step: string;
|
|
141
172
|
readonly days: number;
|
|
142
173
|
}) => Effect.Effect<TranscriptsResult, Error>;
|
|
174
|
+
readonly pipelineStatus: (request: {
|
|
175
|
+
readonly step: string;
|
|
176
|
+
readonly changeRequestId: string;
|
|
177
|
+
}) => Effect.Effect<PipelineStatus, Error>;
|
|
178
|
+
readonly reportPipeline: (request: {
|
|
179
|
+
readonly step: string;
|
|
180
|
+
readonly changeRequestId: string;
|
|
181
|
+
readonly verification: string;
|
|
182
|
+
}) => Effect.Effect<ReportPipelineResult, Error>;
|
|
183
|
+
readonly reviewThreads: (request: {
|
|
184
|
+
readonly step: string;
|
|
185
|
+
readonly changeRequestId: string;
|
|
186
|
+
}) => Effect.Effect<ReviewThreads, Error>;
|
|
187
|
+
readonly openChangeRequests: (request: {
|
|
188
|
+
readonly step: string;
|
|
189
|
+
readonly authors: readonly [string, ...string[]];
|
|
190
|
+
}) => Effect.Effect<OpenChangeRequests, Error>;
|
|
191
|
+
readonly ownChangeRequests: (request: {
|
|
192
|
+
readonly step: string;
|
|
193
|
+
}) => Effect.Effect<OwnChangeRequests, Error>;
|
|
143
194
|
readonly propose: (request: {
|
|
144
195
|
readonly step: string;
|
|
145
196
|
readonly proposal: ProposeRequest;
|
|
146
197
|
}) => Effect.Effect<{
|
|
147
198
|
readonly kind: 'memory' | 'task';
|
|
148
199
|
readonly id: string;
|
|
200
|
+
readonly matched?: boolean;
|
|
149
201
|
}, Error>;
|
|
150
202
|
readonly readProject: (request: {
|
|
151
203
|
readonly step: string;
|
|
@@ -160,7 +212,42 @@ export type ProgramCapabilities = {
|
|
|
160
212
|
readonly mergeChangeRequest: (request: {
|
|
161
213
|
readonly step: string;
|
|
162
214
|
readonly changeRequestId: string;
|
|
215
|
+
readonly head?: string;
|
|
163
216
|
}) => Effect.Effect<MergeResult, Error>;
|
|
217
|
+
readonly closeChangeRequest: (request: {
|
|
218
|
+
readonly step: string;
|
|
219
|
+
readonly number: string;
|
|
220
|
+
readonly head: string;
|
|
221
|
+
readonly note: string;
|
|
222
|
+
}) => Effect.Effect<{
|
|
223
|
+
readonly closed: boolean;
|
|
224
|
+
readonly head?: string;
|
|
225
|
+
}, Error>;
|
|
226
|
+
readonly approveChangeRequest: (request: {
|
|
227
|
+
readonly step: string;
|
|
228
|
+
readonly changeRequestId: string;
|
|
229
|
+
readonly head: string;
|
|
230
|
+
readonly summary: string;
|
|
231
|
+
readonly review?: string;
|
|
232
|
+
readonly carries?: string;
|
|
233
|
+
}) => Effect.Effect<{
|
|
234
|
+
readonly approved: true;
|
|
235
|
+
readonly reviewId: string;
|
|
236
|
+
} | {
|
|
237
|
+
readonly approved: false;
|
|
238
|
+
readonly reason: string;
|
|
239
|
+
}, Error>;
|
|
240
|
+
readonly rerunPipeline: (request: {
|
|
241
|
+
readonly step: string;
|
|
242
|
+
} & ({
|
|
243
|
+
readonly changeRequestId: string;
|
|
244
|
+
} | {
|
|
245
|
+
readonly ref: string;
|
|
246
|
+
readonly all?: boolean;
|
|
247
|
+
})) => Effect.Effect<{
|
|
248
|
+
readonly head: string;
|
|
249
|
+
readonly pipelines: number;
|
|
250
|
+
}, Error>;
|
|
164
251
|
readonly publishRelease: (request: {
|
|
165
252
|
readonly step: string;
|
|
166
253
|
readonly tag: string;
|
|
@@ -184,6 +271,11 @@ export declare class JournalWriteFailed extends JournalWriteFailed_base<{
|
|
|
184
271
|
}
|
|
185
272
|
/** A refusal of the request itself, as opposed to a lost lease or a failure of Kitman's. */
|
|
186
273
|
export declare const refusedStep: (cause: Error) => boolean;
|
|
274
|
+
/**
|
|
275
|
+
* A refused capability or request (a 4xx such as an unpublished child Loop) fails the Step; a lost lease or a failure
|
|
276
|
+
* of Kitman's means this turn ends, and a replay asks again.
|
|
277
|
+
*/
|
|
278
|
+
export declare const requested: <A, R>(step: string, request: Effect.Effect<A, Error, R>) => Effect.Effect<A, StepFailed, R>;
|
|
187
279
|
/** What uploading a Run File asks of Kitman, under whichever lease its maker holds. */
|
|
188
280
|
export type RunFileClient = Pick<ProgramCapabilities, 'createRunFile' | 'runFileParts' | 'completeRunFile'>;
|
|
189
281
|
type FileServices = FileSystem.FileSystem | HttpClient.HttpClient;
|