@kitman-sh/sdk 0.0.0-stage → 0.7.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/dist/build/index.js +215 -0
- package/dist/chunk-7hwhxthh.js +1055 -0
- package/dist/chunk-zp7s46pz.js +3966 -0
- package/dist/loop/index.js +193 -0
- package/dist/program/index.js +30 -0
- package/package.json +29 -4
- package/types/packages/core/src/a2a.d.ts +577 -0
- package/types/packages/core/src/agent-capabilities.d.ts +1434 -0
- package/types/packages/core/src/agent-environment.d.ts +2429 -0
- package/types/packages/core/src/agent-launch-snapshot.d.ts +44 -0
- package/types/packages/core/src/agent-sandbox-policy.d.ts +33 -0
- package/types/packages/core/src/approval-queue.d.ts +126 -0
- package/types/packages/core/src/audit.d.ts +52 -0
- package/types/packages/core/src/change-delivery.d.ts +39 -0
- package/types/packages/core/src/change-request-review.d.ts +146 -0
- package/types/packages/core/src/change-request.d.ts +432 -0
- package/types/packages/core/src/common.d.ts +6 -0
- package/types/packages/core/src/connection.d.ts +33 -0
- package/types/packages/core/src/context-feedback.d.ts +89 -0
- package/types/packages/core/src/context-pack.d.ts +182 -0
- package/types/packages/core/src/crypto.d.ts +11 -0
- package/types/packages/core/src/data-lifecycle.d.ts +195 -0
- package/types/packages/core/src/decision.d.ts +48 -0
- package/types/packages/core/src/delivery-operation.d.ts +125 -0
- package/types/packages/core/src/delivery-policy.d.ts +174 -0
- package/types/packages/core/src/engineering-resources.d.ts +26 -0
- package/types/packages/core/src/enterprise-code-host.d.ts +18 -0
- package/types/packages/core/src/epic-delivery.d.ts +38 -0
- package/types/packages/core/src/extension.d.ts +35 -0
- package/types/packages/core/src/external-effect.d.ts +313 -0
- package/types/packages/core/src/fix-flow.d.ts +149 -0
- package/types/packages/core/src/following.d.ts +59 -0
- package/types/packages/core/src/github-delivery-fixtures.d.ts +28 -0
- package/types/packages/core/src/github-delivery.d.ts +78 -0
- package/types/packages/core/src/gitlab-delivery-fixtures.d.ts +26 -0
- package/types/packages/core/src/gitlab-delivery.d.ts +76 -0
- package/types/packages/core/src/global-search.d.ts +42 -0
- package/types/packages/core/src/id.d.ts +1 -0
- package/types/packages/core/src/index.d.ts +74 -0
- package/types/packages/core/src/integration.d.ts +255 -0
- package/types/packages/core/src/intent.d.ts +260 -0
- package/types/packages/core/src/json.d.ts +10 -0
- package/types/packages/core/src/kit-taxonomy.d.ts +21 -0
- package/types/packages/core/src/kit.d.ts +1489 -0
- package/types/packages/core/src/live.d.ts +8309 -0
- package/types/packages/core/src/loop-layers.d.ts +59 -0
- package/types/packages/core/src/loop-version.d.ts +59 -0
- package/types/packages/core/src/loop.d.ts +3076 -0
- package/types/packages/core/src/me.d.ts +31 -0
- package/types/packages/core/src/memory.d.ts +88 -0
- package/types/packages/core/src/my-teams.d.ts +1230 -0
- package/types/packages/core/src/notification.d.ts +181 -0
- package/types/packages/core/src/observability.d.ts +175 -0
- package/types/packages/core/src/package-declarations.d.ts +435 -0
- package/types/packages/core/src/package.d.ts +369 -0
- package/types/packages/core/src/personal-development-profile.d.ts +11 -0
- package/types/packages/core/src/platform-release.d.ts +60 -0
- package/types/packages/core/src/program-credential.d.ts +10 -0
- package/types/packages/core/src/project.d.ts +66 -0
- package/types/packages/core/src/proposal.d.ts +292 -0
- package/types/packages/core/src/provider-safe-text.d.ts +2 -0
- package/types/packages/core/src/redaction.d.ts +73 -0
- package/types/packages/core/src/repo-binding.d.ts +131 -0
- package/types/packages/core/src/run-journal.d.ts +28 -0
- package/types/packages/core/src/run-launch.d.ts +67 -0
- package/types/packages/core/src/run.d.ts +566 -0
- package/types/packages/core/src/runner-eligibility.d.ts +43 -0
- package/types/packages/core/src/runner-routing.d.ts +11 -0
- package/types/packages/core/src/runner-trust.d.ts +67 -0
- package/types/packages/core/src/runner.d.ts +3750 -0
- package/types/packages/core/src/runtime-type.d.ts +36 -0
- package/types/packages/core/src/schedule.d.ts +136 -0
- package/types/packages/core/src/schema.d.ts +89 -0
- package/types/packages/core/src/scope-directory.d.ts +100 -0
- package/types/packages/core/src/secret.d.ts +37 -0
- package/types/packages/core/src/session.d.ts +90 -0
- package/types/packages/core/src/step-brief.d.ts +50 -0
- package/types/packages/core/src/sync-kit.d.ts +587 -0
- package/types/packages/core/src/task-detail.d.ts +491 -0
- package/types/packages/core/src/task-execution-record.d.ts +620 -0
- package/types/packages/core/src/task-key.d.ts +9 -0
- package/types/packages/core/src/task.d.ts +543 -0
- package/types/packages/core/src/trigger-dispatch.d.ts +421 -0
- package/types/packages/core/src/work-unit.d.ts +740 -0
- package/types/packages/core/src/workspace.d.ts +96 -0
- package/types/packages/live/src/rpc/runner-client.d.ts +947 -0
- package/types/packages/live/src/rpc/runner-group.d.ts +733 -0
- package/types/packages/sdk/src/build/index.d.ts +45 -0
- package/types/packages/sdk/src/loop/activities.d.ts +187 -0
- package/types/packages/sdk/src/loop/check.d.ts +39 -0
- package/types/packages/sdk/src/loop/config.d.ts +68 -0
- package/types/packages/sdk/src/loop/define.d.ts +76 -0
- package/types/packages/sdk/src/loop/evidence.d.ts +66 -0
- package/types/packages/sdk/src/loop/index.d.ts +9 -0
- package/types/packages/sdk/src/loop/plan.d.ts +43 -0
- package/types/packages/sdk/src/loop/review.d.ts +86 -0
- package/types/packages/sdk/src/loop/steps.d.ts +224 -0
- package/types/packages/sdk/src/loop/test-loop.d.ts +112 -0
- package/types/packages/sdk/src/program/engine.d.ts +144 -0
- package/types/packages/sdk/src/program/host.d.ts +70 -0
- package/types/packages/sdk/src/program/index.d.ts +2 -0
- package/README.md +0 -3
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import * as Cause from 'effect/Cause';
|
|
2
|
+
import * as Context from 'effect/Context';
|
|
3
|
+
import * as Duration from 'effect/Duration';
|
|
4
|
+
import * as Effect from 'effect/Effect';
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { DurableDeferred } from 'effect/workflow';
|
|
7
|
+
import { type EventFilter, type LoopCapability, type LoopDefinition, type LoopSchema } from './define';
|
|
8
|
+
declare const StepFailed_base: Schema.Class<StepFailed, Schema.TaggedStruct<"StepFailed", {
|
|
9
|
+
readonly step: Schema.String;
|
|
10
|
+
readonly reason: Schema.String;
|
|
11
|
+
}>, Cause.YieldableError>;
|
|
12
|
+
export declare class StepFailed extends StepFailed_base {
|
|
13
|
+
get message(): string;
|
|
14
|
+
}
|
|
15
|
+
declare const OutputInvalid_base: Schema.Class<OutputInvalid, Schema.TaggedStruct<"OutputInvalid", {
|
|
16
|
+
readonly step: Schema.String;
|
|
17
|
+
readonly message: Schema.String;
|
|
18
|
+
}>, Cause.YieldableError>;
|
|
19
|
+
export declare class OutputInvalid extends OutputInvalid_base {
|
|
20
|
+
}
|
|
21
|
+
declare const QuestionRefused_base: Schema.Class<QuestionRefused, Schema.TaggedStruct<"QuestionRefused", {
|
|
22
|
+
readonly step: Schema.String;
|
|
23
|
+
readonly answer: Schema.String;
|
|
24
|
+
readonly options: Schema.$Array<Schema.String>;
|
|
25
|
+
}>, Cause.YieldableError>;
|
|
26
|
+
export declare class QuestionRefused extends QuestionRefused_base {
|
|
27
|
+
}
|
|
28
|
+
declare const WaitTimedOut_base: Schema.Class<WaitTimedOut, Schema.TaggedStruct<"WaitTimedOut", {
|
|
29
|
+
readonly step: Schema.String;
|
|
30
|
+
readonly event: Schema.String;
|
|
31
|
+
}>, Cause.YieldableError>;
|
|
32
|
+
export declare class WaitTimedOut extends WaitTimedOut_base {
|
|
33
|
+
}
|
|
34
|
+
declare const ChildFailed_base: Schema.Class<ChildFailed, Schema.TaggedStruct<"ChildFailed", {
|
|
35
|
+
readonly step: Schema.String;
|
|
36
|
+
readonly loop: Schema.String;
|
|
37
|
+
readonly reason: Schema.String;
|
|
38
|
+
}>, Cause.YieldableError>;
|
|
39
|
+
export declare class ChildFailed extends ChildFailed_base {
|
|
40
|
+
get message(): string;
|
|
41
|
+
}
|
|
42
|
+
declare const CapabilityDenied_base: Schema.Class<CapabilityDenied, Schema.TaggedStruct<"CapabilityDenied", {
|
|
43
|
+
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"]>;
|
|
45
|
+
/** A Secret the Step names that its Loop does not declare. */
|
|
46
|
+
readonly secret: Schema.optionalKey<Schema.String>;
|
|
47
|
+
}>, Cause.YieldableError>;
|
|
48
|
+
export declare class CapabilityDenied extends CapabilityDenied_base {
|
|
49
|
+
get message(): string;
|
|
50
|
+
}
|
|
51
|
+
declare const DuplicateStep_base: Schema.Class<DuplicateStep, Schema.TaggedStruct<"DuplicateStep", {
|
|
52
|
+
readonly step: Schema.String;
|
|
53
|
+
}>, Cause.YieldableError>;
|
|
54
|
+
export declare class DuplicateStep extends DuplicateStep_base {
|
|
55
|
+
}
|
|
56
|
+
declare const InputInvalid_base: Schema.Class<InputInvalid, Schema.TaggedStruct<"InputInvalid", {
|
|
57
|
+
readonly loop: Schema.String;
|
|
58
|
+
readonly message: Schema.String;
|
|
59
|
+
}>, Cause.YieldableError>;
|
|
60
|
+
export declare class InputInvalid extends InputInvalid_base {
|
|
61
|
+
}
|
|
62
|
+
export declare const LoopEvent: Schema.Struct<{
|
|
63
|
+
readonly type: Schema.String;
|
|
64
|
+
readonly payload: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
65
|
+
}>;
|
|
66
|
+
export type LoopEvent = typeof LoopEvent.Type;
|
|
67
|
+
export type StepKind = 'agent_work' | 'ask' | 'call' | 'wait_for' | 'verify' | 'change_request' | 'write_back' | 'artifact' | 'note' | 'comment' | 'create_tasks' | 'integration_branch' | 'merge_change_request' | 'release';
|
|
68
|
+
/** A Step a Run took, as its program saw it. */
|
|
69
|
+
export type StepRecord = {
|
|
70
|
+
readonly name: string;
|
|
71
|
+
readonly kind: StepKind;
|
|
72
|
+
readonly status: 'succeeded';
|
|
73
|
+
readonly result: unknown;
|
|
74
|
+
} | {
|
|
75
|
+
readonly name: string;
|
|
76
|
+
readonly kind: StepKind;
|
|
77
|
+
readonly status: 'failed';
|
|
78
|
+
readonly error: unknown;
|
|
79
|
+
};
|
|
80
|
+
declare const LoopRun_base: Context.ServiceClass<LoopRun, "@kitman-sh/sdk/loop/LoopRun", {
|
|
81
|
+
readonly loop: string;
|
|
82
|
+
readonly agents: {
|
|
83
|
+
readonly [role: string]: string;
|
|
84
|
+
};
|
|
85
|
+
readonly granted: ReadonlySet<LoopCapability>;
|
|
86
|
+
/** The Secrets the Loop declares. */
|
|
87
|
+
readonly secrets: ReadonlySet<string>;
|
|
88
|
+
readonly names: Set<string>;
|
|
89
|
+
readonly steps: StepRecord[];
|
|
90
|
+
}>;
|
|
91
|
+
/** One execution of a Run's program; a replay starts a fresh one. */
|
|
92
|
+
export declare class LoopRun extends LoopRun_base {
|
|
93
|
+
}
|
|
94
|
+
type Launch = {
|
|
95
|
+
readonly step: string;
|
|
96
|
+
readonly token: DurableDeferred.Token;
|
|
97
|
+
};
|
|
98
|
+
export type AgentWorkLaunch = Launch & {
|
|
99
|
+
readonly role: string;
|
|
100
|
+
readonly agent: string;
|
|
101
|
+
readonly prompt: string;
|
|
102
|
+
/** JSON Schema the Output must match. */
|
|
103
|
+
readonly output: Schema.Json;
|
|
104
|
+
/** Secrets for the agent's sandbox environment. */
|
|
105
|
+
readonly secrets?: readonly string[];
|
|
106
|
+
};
|
|
107
|
+
/** A verification a human may approve for the repository; nothing runs it until they do. */
|
|
108
|
+
export type SuggestedVerification = {
|
|
109
|
+
readonly name: string;
|
|
110
|
+
readonly command: string;
|
|
111
|
+
readonly workingDirectory?: string;
|
|
112
|
+
};
|
|
113
|
+
export type QuestionLaunch = Launch & {
|
|
114
|
+
readonly prompt: string;
|
|
115
|
+
readonly options?: readonly string[];
|
|
116
|
+
/** Approving the Question approves this verification. */
|
|
117
|
+
readonly verification?: SuggestedVerification;
|
|
118
|
+
};
|
|
119
|
+
export type VerificationLaunch = Launch & {
|
|
120
|
+
/** The Run's head when left out. */
|
|
121
|
+
readonly revision?: string;
|
|
122
|
+
/** Approved verifications by name; all of them when left out. */
|
|
123
|
+
readonly checks?: readonly string[];
|
|
124
|
+
};
|
|
125
|
+
export type ChildLaunch = Launch & {
|
|
126
|
+
readonly loop: string;
|
|
127
|
+
readonly input: Schema.Json;
|
|
128
|
+
};
|
|
129
|
+
export type EventWaitLaunch = Launch & {
|
|
130
|
+
readonly event: string;
|
|
131
|
+
readonly filter?: EventFilter;
|
|
132
|
+
readonly timeoutMillis: number;
|
|
133
|
+
};
|
|
134
|
+
declare const LoopHost_base: Context.ServiceClass<LoopHost, "@kitman-sh/sdk/loop/LoopHost", {
|
|
135
|
+
readonly startAgentWork: (launch: AgentWorkLaunch) => Effect.Effect<void, StepFailed>;
|
|
136
|
+
readonly putQuestion: (launch: QuestionLaunch) => Effect.Effect<void, StepFailed>;
|
|
137
|
+
readonly admitChild: (launch: ChildLaunch) => Effect.Effect<void, StepFailed>;
|
|
138
|
+
readonly awaitEvent: (launch: EventWaitLaunch) => Effect.Effect<void, StepFailed>;
|
|
139
|
+
readonly startVerification: (launch: VerificationLaunch) => Effect.Effect<void, StepFailed>;
|
|
140
|
+
}>;
|
|
141
|
+
/**
|
|
142
|
+
* What Kitman lends a program: each launch hands Kitman a deferred token, and Kitman resolves it with the
|
|
143
|
+
* Output, answer, child result or Event.
|
|
144
|
+
*/
|
|
145
|
+
export declare class LoopHost extends LoopHost_base {
|
|
146
|
+
}
|
|
147
|
+
export declare const agentWorkDeferred: (step: string) => DurableDeferred.DurableDeferred<Schema.Codec<Schema.Json, Schema.Json, never, never>, typeof StepFailed>;
|
|
148
|
+
export declare const answerDeferred: (step: string) => DurableDeferred.DurableDeferred<Schema.String, typeof StepFailed>;
|
|
149
|
+
export declare const childDeferred: (step: string) => DurableDeferred.DurableDeferred<Schema.Codec<Schema.Json, Schema.Json, never, never>, typeof ChildFailed>;
|
|
150
|
+
export declare const eventDeferred: (step: string) => DurableDeferred.DurableDeferred<Schema.Struct<{
|
|
151
|
+
readonly type: Schema.String;
|
|
152
|
+
readonly payload: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
153
|
+
}>, typeof WaitTimedOut>;
|
|
154
|
+
export declare const verifyDeferred: (step: string) => DurableDeferred.DurableDeferred<Schema.Struct<{
|
|
155
|
+
readonly revision: Schema.String;
|
|
156
|
+
readonly tree: Schema.String;
|
|
157
|
+
readonly passed: Schema.Boolean;
|
|
158
|
+
readonly checks: Schema.$Array<Schema.Struct<{
|
|
159
|
+
readonly name: Schema.String;
|
|
160
|
+
readonly command: Schema.String;
|
|
161
|
+
readonly status: Schema.Literals<readonly ["passed", "failed"]>;
|
|
162
|
+
readonly preExisting: Schema.Boolean;
|
|
163
|
+
readonly durationMs: Schema.Finite;
|
|
164
|
+
readonly evidenceId: Schema.String;
|
|
165
|
+
}>>;
|
|
166
|
+
}>, typeof StepFailed>;
|
|
167
|
+
/** Claims the Step name for this Run and checks its capability before running it. */
|
|
168
|
+
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>;
|
|
169
|
+
/**
|
|
170
|
+
* 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.
|
|
172
|
+
*/
|
|
173
|
+
export declare const agentWork: <Out>(name: string, options: {
|
|
174
|
+
readonly agent: string;
|
|
175
|
+
readonly prompt: string;
|
|
176
|
+
readonly output: LoopSchema<Out>;
|
|
177
|
+
readonly secrets?: readonly string[];
|
|
178
|
+
}) => Effect.Effect<Out, CapabilityDenied | DuplicateStep | OutputInvalid | StepFailed, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
179
|
+
type Question<Options extends readonly string[]> = {
|
|
180
|
+
readonly prompt: string;
|
|
181
|
+
readonly options: Options;
|
|
182
|
+
} | {
|
|
183
|
+
readonly prompt: string;
|
|
184
|
+
readonly freeText: true;
|
|
185
|
+
};
|
|
186
|
+
/** Puts a Question to a human; an answer outside `options` is refused. */
|
|
187
|
+
export declare const ask: <const Options extends readonly string[]>(name: string, question: Question<Options>) => Effect.Effect<string, CapabilityDenied | DuplicateStep | QuestionRefused | StepFailed, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
188
|
+
/** Starts a Child Run of `loop` and awaits its output. */
|
|
189
|
+
export declare const call: <In, Out, E>(name: string, loop: LoopDefinition<In, Out, E>, input: In) => Effect.Effect<Out, CapabilityDenied | ChildFailed | DuplicateStep | StepFailed, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
190
|
+
/** Waits for an Event matching `filter`, which is data the control plane matches. */
|
|
191
|
+
export declare const waitFor: (name: string, wait: {
|
|
192
|
+
readonly event: string;
|
|
193
|
+
readonly filter?: EventFilter;
|
|
194
|
+
readonly timeout: Duration.Input;
|
|
195
|
+
}) => Effect.Effect<{
|
|
196
|
+
readonly type: string;
|
|
197
|
+
readonly payload: {
|
|
198
|
+
readonly [x: string]: Schema.Json;
|
|
199
|
+
};
|
|
200
|
+
}, CapabilityDenied | DuplicateStep | StepFailed | WaitTimedOut, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
201
|
+
/**
|
|
202
|
+
* Runs the repository's approved verifications at `revision`, or by default at the Run's head (what its Steps last
|
|
203
|
+
* 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 default branch is marked pre-existing.
|
|
205
|
+
*/
|
|
206
|
+
export declare const verify: (name: string, request: {
|
|
207
|
+
readonly revision?: string;
|
|
208
|
+
readonly checks?: readonly string[];
|
|
209
|
+
}) => Effect.Effect<{
|
|
210
|
+
readonly revision: string;
|
|
211
|
+
readonly tree: string;
|
|
212
|
+
readonly passed: boolean;
|
|
213
|
+
readonly checks: readonly {
|
|
214
|
+
readonly name: string;
|
|
215
|
+
readonly command: string;
|
|
216
|
+
readonly status: "failed" | "passed";
|
|
217
|
+
readonly preExisting: boolean;
|
|
218
|
+
readonly durationMs: number;
|
|
219
|
+
readonly evidenceId: string;
|
|
220
|
+
}[];
|
|
221
|
+
}, CapabilityDenied | DuplicateStep | StepFailed, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
222
|
+
/** Asks a human to approve a verification, for example one an agent's Output suggested. */
|
|
223
|
+
export declare const suggestVerification: (name: string, verification: SuggestedVerification) => Effect.Effect<"approved" | "rejected", CapabilityDenied | DuplicateStep | StepFailed, LoopHost | LoopRun | import("effect/workflow/WorkflowEngine").WorkflowEngine | import("effect/workflow/WorkflowEngine").WorkflowInstance>;
|
|
224
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as Effect from 'effect/Effect';
|
|
2
|
+
import * as Exit from 'effect/Exit';
|
|
3
|
+
import * as Schema from 'effect/Schema';
|
|
4
|
+
import { Workflow, WorkflowEngine } from 'effect/workflow';
|
|
5
|
+
import { ArtifactActivity, ChangeRequestActivity, CommentActivity, CreateTasksActivity, IntegrationBranchActivity, MergeChangeRequestActivity, NoteActivity, ReleaseActivity, WriteBackActivity } from './activities';
|
|
6
|
+
import type { LoopCapability, LoopDefinition } from './define';
|
|
7
|
+
import type { VerifyResult } from './evidence';
|
|
8
|
+
import { InputInvalid, LoopHost, LoopRun, type LoopEvent, type StepRecord } from './steps';
|
|
9
|
+
/** Activity and deferred results, encoded as JSON; replaying from it runs no Activity again. */
|
|
10
|
+
export declare const LoopJournal: Schema.Struct<{
|
|
11
|
+
readonly activities: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
12
|
+
readonly deferreds: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
13
|
+
}>;
|
|
14
|
+
export type LoopJournal = typeof LoopJournal.Type;
|
|
15
|
+
declare const ScriptedFailure_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Readonly<A> & {
|
|
16
|
+
readonly _tag: "ScriptedFailure";
|
|
17
|
+
} & import("effect/Pipeable").Pipeable;
|
|
18
|
+
export declare class ScriptedFailure extends ScriptedFailure_base<{
|
|
19
|
+
readonly reason: string;
|
|
20
|
+
}> {
|
|
21
|
+
}
|
|
22
|
+
/** Scripts a failed agent Step or Child Run. */
|
|
23
|
+
export declare const scriptedFailure: (reason: string) => ScriptedFailure;
|
|
24
|
+
type Scripted = Schema.Json | ScriptedFailure;
|
|
25
|
+
export type HostActivities = {
|
|
26
|
+
readonly changeRequest: ChangeRequestActivity['Service'];
|
|
27
|
+
readonly writeBack: WriteBackActivity['Service'];
|
|
28
|
+
readonly artifact: ArtifactActivity['Service'];
|
|
29
|
+
readonly note: NoteActivity['Service'];
|
|
30
|
+
readonly comment: CommentActivity['Service'];
|
|
31
|
+
readonly createTasks: CreateTasksActivity['Service'];
|
|
32
|
+
readonly integrationBranch: IntegrationBranchActivity['Service'];
|
|
33
|
+
readonly mergeChangeRequest: MergeChangeRequestActivity['Service'];
|
|
34
|
+
readonly release: ReleaseActivity['Service'];
|
|
35
|
+
};
|
|
36
|
+
export type TestLoopScript = {
|
|
37
|
+
/** The Loop Input as JSON, as a Run receives it. */
|
|
38
|
+
readonly input: Schema.Json;
|
|
39
|
+
/** Outputs by Step name; a Step left out fails. */
|
|
40
|
+
readonly outputs?: {
|
|
41
|
+
readonly [step: string]: Scripted;
|
|
42
|
+
};
|
|
43
|
+
readonly answers?: {
|
|
44
|
+
readonly [step: string]: string;
|
|
45
|
+
};
|
|
46
|
+
readonly children?: {
|
|
47
|
+
readonly [step: string]: Scripted;
|
|
48
|
+
};
|
|
49
|
+
/** Events by Step name; a waitFor left out times out. */
|
|
50
|
+
readonly events?: {
|
|
51
|
+
readonly [step: string]: LoopEvent;
|
|
52
|
+
};
|
|
53
|
+
/** Verification results by Step name; a verify left out passes with no checks. */
|
|
54
|
+
readonly verifications?: {
|
|
55
|
+
readonly [step: string]: VerifyResult | ScriptedFailure;
|
|
56
|
+
};
|
|
57
|
+
/** What the control plane grants; the declared capabilities by default. */
|
|
58
|
+
readonly grant?: readonly LoopCapability[];
|
|
59
|
+
readonly activities?: Partial<HostActivities>;
|
|
60
|
+
readonly journal?: LoopJournal;
|
|
61
|
+
/** Secret values the program reads with `Config`; none by default. */
|
|
62
|
+
readonly secrets?: {
|
|
63
|
+
readonly [name: string]: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/** A check run twice, once from the journal: a Loop's `checks`, or a stored Loop module's `checks` export. */
|
|
67
|
+
export type LoopCheck = {
|
|
68
|
+
readonly name: string;
|
|
69
|
+
readonly script: TestLoopScript;
|
|
70
|
+
};
|
|
71
|
+
export type TestLoopResult<Out, E> = {
|
|
72
|
+
readonly result: Exit.Exit<Out, E | InputInvalid>;
|
|
73
|
+
readonly steps: readonly StepRecord[];
|
|
74
|
+
readonly journal: LoopJournal;
|
|
75
|
+
/** Activities that ran rather than replayed from the journal. */
|
|
76
|
+
readonly activities: readonly string[];
|
|
77
|
+
readonly agentLaunches: readonly AgentLaunchRecord[];
|
|
78
|
+
/** Child Runs admitted, with their Input as JSON, in admission order. */
|
|
79
|
+
readonly childLaunches: readonly ChildLaunchRecord[];
|
|
80
|
+
};
|
|
81
|
+
type AgentLaunchRecord = {
|
|
82
|
+
readonly step: string;
|
|
83
|
+
readonly agent: string;
|
|
84
|
+
readonly prompt: string;
|
|
85
|
+
readonly secrets?: readonly string[];
|
|
86
|
+
};
|
|
87
|
+
type ChildLaunchRecord = {
|
|
88
|
+
readonly step: string;
|
|
89
|
+
readonly loop: string;
|
|
90
|
+
readonly input: Schema.Json;
|
|
91
|
+
};
|
|
92
|
+
/** The workflow a Loop's program runs as; a Run is one execution of it. */
|
|
93
|
+
export declare const loopWorkflow: <In, Out, E>(loop: LoopDefinition<In, Out, E>) => Workflow.Workflow<`kitman-loop/${string}`, Schema.Struct<{
|
|
94
|
+
input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
95
|
+
}>, import("./define").LoopSchema<Out>, Schema.declare<E | InputInvalid, E | InputInvalid>>;
|
|
96
|
+
export type LoopRuntime = {
|
|
97
|
+
readonly host: LoopHost['Service'];
|
|
98
|
+
readonly activities: HostActivities;
|
|
99
|
+
/** The declared capabilities the control plane granted. */
|
|
100
|
+
readonly granted: ReadonlySet<LoopCapability>;
|
|
101
|
+
readonly onRun?: (run: LoopRun['Service']) => void;
|
|
102
|
+
};
|
|
103
|
+
/** Decodes the Loop Input and runs the program with what Kitman lends it; the engine comes from the caller. */
|
|
104
|
+
export declare const executeLoop: <In, Out, E>(loop: LoopDefinition<In, Out, E>, runtime: LoopRuntime) => ({ input }: {
|
|
105
|
+
readonly input: Schema.Json;
|
|
106
|
+
}) => Effect.Effect<Out, E | InputInvalid, WorkflowEngine.WorkflowEngine | WorkflowEngine.WorkflowInstance>;
|
|
107
|
+
/**
|
|
108
|
+
* Runs a Loop on Effect's in-memory workflow engine with scripted Outputs, answers, child results and Events.
|
|
109
|
+
* Given a `journal`, it replays from it.
|
|
110
|
+
*/
|
|
111
|
+
export declare const testLoop: <In, Out, E>(loop: LoopDefinition<In, Out, E>, script: TestLoopScript) => Effect.Effect<TestLoopResult<Out, E>>;
|
|
112
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { type OrchestrationWorkUnit, type ProgramWorkUnit } from '../../../core/src/index';
|
|
2
|
+
import { type ChangeRequestResult, type EventFilter, type IntegrationBranch, type LoopDefinition, type MergeResult, type ReleaseResult, type PlanTicket, type WriteBackMilestones, type SuggestedVerification } from '../loop';
|
|
3
|
+
import * as Cause from 'effect/Cause';
|
|
4
|
+
import * as Effect from 'effect/Effect';
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { type ProgramLease } from '../../../live/src/rpc/runner-group';
|
|
7
|
+
import type { RunnerRpcClient } from '../../../live/src/rpc/runner-client';
|
|
8
|
+
type WriteBackMilestone = (typeof WriteBackMilestones)[number];
|
|
9
|
+
/** The journal writes one orchestration lease may make; the control plane fences each one. */
|
|
10
|
+
export type ProgramJournal = {
|
|
11
|
+
readonly recordActivity: (entry: {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly attempt: number;
|
|
14
|
+
readonly exit: Schema.Json;
|
|
15
|
+
}) => Effect.Effect<void, Error>;
|
|
16
|
+
readonly deferredDone: (entry: {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly exit: Schema.Json;
|
|
19
|
+
}) => Effect.Effect<void, Error>;
|
|
20
|
+
readonly scheduleClock: (clock: {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly deferredName: string;
|
|
23
|
+
readonly durationMillis: number;
|
|
24
|
+
}) => Effect.Effect<void, Error>;
|
|
25
|
+
readonly putQuestion: (question: {
|
|
26
|
+
readonly step: string;
|
|
27
|
+
readonly prompt: string;
|
|
28
|
+
readonly options?: readonly string[];
|
|
29
|
+
readonly verification?: SuggestedVerification;
|
|
30
|
+
readonly deferredName: string;
|
|
31
|
+
}) => Effect.Effect<{
|
|
32
|
+
readonly questionId: string;
|
|
33
|
+
}, Error>;
|
|
34
|
+
readonly startVerification: (verification: {
|
|
35
|
+
readonly step: string;
|
|
36
|
+
readonly deferredName: string;
|
|
37
|
+
readonly revision?: string;
|
|
38
|
+
readonly checks?: readonly string[];
|
|
39
|
+
}) => Effect.Effect<{
|
|
40
|
+
readonly verificationId: string;
|
|
41
|
+
}, Error>;
|
|
42
|
+
readonly startAgentStep: (step: {
|
|
43
|
+
readonly step: string;
|
|
44
|
+
readonly deferredName: string;
|
|
45
|
+
readonly role: string;
|
|
46
|
+
readonly agentId: string;
|
|
47
|
+
readonly prompt: string;
|
|
48
|
+
readonly outputSchema: Schema.Json;
|
|
49
|
+
readonly secrets?: readonly string[];
|
|
50
|
+
}) => Effect.Effect<{
|
|
51
|
+
readonly stepAttemptId: string;
|
|
52
|
+
}, Error>;
|
|
53
|
+
readonly awaitEvent: (wait: {
|
|
54
|
+
readonly step: string;
|
|
55
|
+
readonly deferredName: string;
|
|
56
|
+
readonly event: string;
|
|
57
|
+
readonly filter?: EventFilter;
|
|
58
|
+
readonly timeoutMillis: number;
|
|
59
|
+
}) => Effect.Effect<void, Error>;
|
|
60
|
+
readonly admitChild: (child: {
|
|
61
|
+
readonly step: string;
|
|
62
|
+
readonly loop: string;
|
|
63
|
+
readonly input: Schema.Json;
|
|
64
|
+
readonly deferredName: string;
|
|
65
|
+
}) => Effect.Effect<{
|
|
66
|
+
readonly runId: string;
|
|
67
|
+
}, Error>;
|
|
68
|
+
readonly storeArtifact: (artifact: {
|
|
69
|
+
readonly step: string;
|
|
70
|
+
readonly kind: string;
|
|
71
|
+
readonly title: string;
|
|
72
|
+
readonly text: string;
|
|
73
|
+
readonly data?: Schema.Json | undefined;
|
|
74
|
+
}) => Effect.Effect<{
|
|
75
|
+
readonly artifactId: string;
|
|
76
|
+
}, Error>;
|
|
77
|
+
readonly recordNote: (note: {
|
|
78
|
+
readonly step: string;
|
|
79
|
+
readonly text: string;
|
|
80
|
+
readonly artifactId?: string | undefined;
|
|
81
|
+
}) => Effect.Effect<void, Error>;
|
|
82
|
+
readonly performHostEffect: (request: {
|
|
83
|
+
readonly step: string;
|
|
84
|
+
readonly effect: {
|
|
85
|
+
readonly kind: 'post_comment';
|
|
86
|
+
readonly changeRequestId: string;
|
|
87
|
+
readonly body: string;
|
|
88
|
+
} | {
|
|
89
|
+
readonly kind: 'change_request';
|
|
90
|
+
readonly title: string;
|
|
91
|
+
readonly body: string;
|
|
92
|
+
readonly integration?: string;
|
|
93
|
+
} | {
|
|
94
|
+
readonly kind: 'write_back';
|
|
95
|
+
readonly milestone?: WriteBackMilestone;
|
|
96
|
+
readonly changeRequestUrl?: string;
|
|
97
|
+
};
|
|
98
|
+
}) => Effect.Effect<ChangeRequestResult | undefined, Error>;
|
|
99
|
+
readonly createPlanTasks: (tickets: readonly PlanTicket[]) => Effect.Effect<readonly {
|
|
100
|
+
readonly key: string;
|
|
101
|
+
readonly taskId: string;
|
|
102
|
+
}[], Error>;
|
|
103
|
+
readonly integrationBranch: (repoBindingId?: string) => Effect.Effect<IntegrationBranch, Error>;
|
|
104
|
+
readonly mergeChangeRequest: (request: {
|
|
105
|
+
readonly step: string;
|
|
106
|
+
readonly changeRequestId: string;
|
|
107
|
+
}) => Effect.Effect<MergeResult, Error>;
|
|
108
|
+
readonly publishRelease: (request: {
|
|
109
|
+
readonly step: string;
|
|
110
|
+
readonly tag: string;
|
|
111
|
+
readonly revision?: string;
|
|
112
|
+
readonly title: string;
|
|
113
|
+
readonly notes: string;
|
|
114
|
+
}) => Effect.Effect<ReleaseResult, Error>;
|
|
115
|
+
readonly suspend: Effect.Effect<void, Error>;
|
|
116
|
+
readonly finish: (outcome: {
|
|
117
|
+
readonly status: 'completed';
|
|
118
|
+
readonly output: Schema.Json;
|
|
119
|
+
} | {
|
|
120
|
+
readonly status: 'failed';
|
|
121
|
+
readonly failureSummary: string;
|
|
122
|
+
}) => Effect.Effect<void, Error>;
|
|
123
|
+
};
|
|
124
|
+
declare const JournalWriteFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
125
|
+
readonly _tag: "JournalWriteFailed";
|
|
126
|
+
} & Readonly<A>;
|
|
127
|
+
/** The control plane refused a journal write, so this replica no longer owns the Run and must report nothing. */
|
|
128
|
+
export declare class JournalWriteFailed extends JournalWriteFailed_base<{
|
|
129
|
+
readonly cause: Error;
|
|
130
|
+
}> {
|
|
131
|
+
get message(): string;
|
|
132
|
+
}
|
|
133
|
+
/** A refusal of the request itself, as opposed to a lost lease or a failure of Kitman's. */
|
|
134
|
+
export declare const refusedStep: (cause: Error) => boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Runs or replays a Run's program for one orchestration lease, and reports what became of it: suspended, with the
|
|
137
|
+
* lease given back; completed; or failed. A refused journal write means the lease is gone, so nothing is reported.
|
|
138
|
+
*/
|
|
139
|
+
export declare const runProgram: <In, Out, E>(loop: LoopDefinition<In, Out, E>, work: ProgramWorkUnit, journal: ProgramJournal) => Effect.Effect<'suspended' | 'completed' | 'failed', JournalWriteFailed>;
|
|
140
|
+
/** A Work Unit's lease as the Runner RPC calls carry it. */
|
|
141
|
+
export declare const programLease: (work: Pick<OrchestrationWorkUnit, 'id' | 'lease'>) => ProgramLease;
|
|
142
|
+
/** The journal over the Runner RPC channel, each write under the Work Unit's lease. */
|
|
143
|
+
export declare const rpcProgramJournal: (rpc: RunnerRpcClient, work: ProgramWorkUnit) => ProgramJournal;
|
|
144
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ProgramLease } from '../../../live/src/rpc/runner-group';
|
|
2
|
+
import { makeRunnerRpcClient } from '../../../live/src/rpc/runner-client';
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
import * as Option from 'effect/Option';
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import type { PackageConfig } from '../loop/config';
|
|
7
|
+
import { ManifestInvalid } from '../loop/define';
|
|
8
|
+
import { type ProgramJournal } from './engine';
|
|
9
|
+
/** Asks a bundle for its declarations and check results instead of running a program. */
|
|
10
|
+
export declare const describeFlag = "--kitman-describe";
|
|
11
|
+
export declare const Described: Schema.Union<readonly [Schema.TaggedStruct<"Described", {
|
|
12
|
+
readonly loops: Schema.$Array<Schema.Struct<{
|
|
13
|
+
readonly id: Schema.String;
|
|
14
|
+
readonly title: Schema.String;
|
|
15
|
+
readonly input: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
16
|
+
readonly output: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
17
|
+
readonly outcome: Schema.optionalKey<Schema.Literals<readonly ["feature", "bug", "refactor", "investigation", "docs", "migration"]>>;
|
|
18
|
+
readonly agents: Schema.$Record<Schema.String, Schema.String>;
|
|
19
|
+
readonly checkout: Schema.Literals<readonly ["none", "read", "write"]>;
|
|
20
|
+
readonly when: Schema.$Array<Schema.Struct<{
|
|
21
|
+
readonly event: Schema.String;
|
|
22
|
+
readonly filter: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.Null]>, Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.Null]>>]>>>;
|
|
23
|
+
readonly input: Schema.$Record<Schema.String, Schema.String>;
|
|
24
|
+
}>>;
|
|
25
|
+
readonly offers: Schema.$Array<Schema.Struct<{
|
|
26
|
+
readonly id: Schema.String;
|
|
27
|
+
readonly title: Schema.String;
|
|
28
|
+
readonly loop: Schema.String;
|
|
29
|
+
}>>;
|
|
30
|
+
readonly capabilities: Schema.$Array<Schema.Literals<readonly ["agent_work", "ask", "call", "verify", "change_request", "write_back", "post_comment", "create_tasks", "merge_change_request", "publish_release"]>>;
|
|
31
|
+
readonly secrets: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
32
|
+
readonly network: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
33
|
+
readonly hosts: Schema.$Array<Schema.String>;
|
|
34
|
+
}>, Schema.Literal<"open">]>>;
|
|
35
|
+
}>>;
|
|
36
|
+
readonly agents: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
37
|
+
readonly schedules: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
|
|
38
|
+
readonly kits: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
|
|
39
|
+
}>, Schema.TaggedStruct<"Refused", {
|
|
40
|
+
readonly error: Schema.Union<readonly [typeof ManifestInvalid, Schema.Union<readonly [typeof import("../loop").CheckFailed, typeof import("../loop").StepNamedTwice, typeof import("../loop").ReplayDiverged]>]>;
|
|
41
|
+
}>]>;
|
|
42
|
+
type SecretsRpc = Pick<Effect.Success<ReturnType<typeof makeRunnerRpcClient>>, 'programSecrets' | 'finishProgram'>;
|
|
43
|
+
/**
|
|
44
|
+
* The Secrets the Loop declares, or none when Kitman refuses them (one deleted while the Run waited): the Run fails
|
|
45
|
+
* then, saying why, since a replay would only be refused again.
|
|
46
|
+
*/
|
|
47
|
+
export declare const programSecrets: (rpc: SecretsRpc, lease: ProgramLease) => Effect.Effect<Option.Option<never> | Option.Option<{
|
|
48
|
+
readonly [x: string]: string;
|
|
49
|
+
}>, Error | import("effect/rpc/RpcClientError").RpcClientError | import("../../../live/src/rpc/runner-group").RunnerRpcError, never>;
|
|
50
|
+
/** Kitman's API host and the Loop's declared hosts, comma-separated, as the Runner passes them; unset for `open`. */
|
|
51
|
+
export declare const programHostsEnv = "KITMAN_PROGRAM_HOSTS";
|
|
52
|
+
/** `fail` where the Runner sandboxes the program, `warn` where it runs on its owner's host. */
|
|
53
|
+
export declare const undeclaredHostsEnv = "KITMAN_UNDECLARED_HOSTS";
|
|
54
|
+
type Fetch = (resource: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
55
|
+
/**
|
|
56
|
+
* `fetch` limited to `hosts`, redirect hops included. An undeclared host is refused, and fails the Run with its name
|
|
57
|
+
* whatever the program then reports; under `warn` it is let through, with one warning per host.
|
|
58
|
+
*/
|
|
59
|
+
export declare const networkGuard: (input: {
|
|
60
|
+
readonly hosts: readonly string[];
|
|
61
|
+
readonly undeclared: 'fail' | 'warn';
|
|
62
|
+
readonly fetch: Fetch;
|
|
63
|
+
readonly warn: (line: string) => void;
|
|
64
|
+
}) => {
|
|
65
|
+
fetch: Fetch;
|
|
66
|
+
journal: <Journal extends Pick<ProgramJournal, 'suspend' | 'finish'>>(journal: Journal) => Journal;
|
|
67
|
+
};
|
|
68
|
+
/** The entry of every Package bundle. */
|
|
69
|
+
export declare const runPackage: (config: PackageConfig) => void;
|
|
70
|
+
export {};
|
package/README.md
DELETED