@kitman-sh/loops 0.0.0-stage → 0.6.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.
Files changed (41) hide show
  1. package/dist/index.js +1066 -0
  2. package/package.json +19 -4
  3. package/types/packages/core/src/agent-environment.d.ts +2429 -0
  4. package/types/packages/core/src/agent-sandbox-policy.d.ts +31 -0
  5. package/types/packages/core/src/common.d.ts +6 -0
  6. package/types/packages/core/src/context-pack.d.ts +182 -0
  7. package/types/packages/core/src/extension.d.ts +35 -0
  8. package/types/packages/core/src/kit.d.ts +1489 -0
  9. package/types/packages/core/src/loop-layers.d.ts +59 -0
  10. package/types/packages/core/src/loop-version.d.ts +59 -0
  11. package/types/packages/core/src/loop.d.ts +3076 -0
  12. package/types/packages/core/src/package-declarations.d.ts +427 -0
  13. package/types/packages/core/src/proposal.d.ts +292 -0
  14. package/types/packages/core/src/redaction.d.ts +73 -0
  15. package/types/packages/core/src/run.d.ts +566 -0
  16. package/types/packages/core/src/runtime-type.d.ts +36 -0
  17. package/types/packages/core/src/schedule.d.ts +136 -0
  18. package/types/packages/core/src/schema.d.ts +89 -0
  19. package/types/packages/core/src/trigger-dispatch.d.ts +421 -0
  20. package/types/packages/loops/src/build.d.ts +33 -0
  21. package/types/packages/loops/src/change-request-body.d.ts +14 -0
  22. package/types/packages/loops/src/code-quality-pass.d.ts +50 -0
  23. package/types/packages/loops/src/code-quality.d.ts +26 -0
  24. package/types/packages/loops/src/hello.d.ts +9 -0
  25. package/types/packages/loops/src/incident.d.ts +13 -0
  26. package/types/packages/loops/src/index.d.ts +172 -0
  27. package/types/packages/loops/src/plan.d.ts +37 -0
  28. package/types/packages/loops/src/release.d.ts +21 -0
  29. package/types/packages/loops/src/research.d.ts +8 -0
  30. package/types/packages/loops/src/review.d.ts +38 -0
  31. package/types/packages/sdk/src/loop/activities.d.ts +187 -0
  32. package/types/packages/sdk/src/loop/check.d.ts +39 -0
  33. package/types/packages/sdk/src/loop/config.d.ts +68 -0
  34. package/types/packages/sdk/src/loop/define.d.ts +69 -0
  35. package/types/packages/sdk/src/loop/evidence.d.ts +66 -0
  36. package/types/packages/sdk/src/loop/index.d.ts +9 -0
  37. package/types/packages/sdk/src/loop/plan.d.ts +43 -0
  38. package/types/packages/sdk/src/loop/review.d.ts +86 -0
  39. package/types/packages/sdk/src/loop/steps.d.ts +224 -0
  40. package/types/packages/sdk/src/loop/test-loop.d.ts +112 -0
  41. package/README.md +0 -3
@@ -0,0 +1,39 @@
1
+ import * as Cause from 'effect/Cause';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as Schema from 'effect/Schema';
4
+ import type { LoopDefinition } from './define';
5
+ import { type LoopCheck } from './test-loop';
6
+ declare const CheckFailed_base: Schema.Class<CheckFailed, Schema.TaggedStruct<"CheckFailed", {
7
+ readonly loop: Schema.String;
8
+ readonly check: Schema.String;
9
+ readonly reason: Schema.String;
10
+ }>, Cause.YieldableError>;
11
+ export declare class CheckFailed extends CheckFailed_base {
12
+ get detail(): string;
13
+ get message(): string;
14
+ }
15
+ declare const StepNamedTwice_base: Schema.Class<StepNamedTwice, Schema.TaggedStruct<"StepNamedTwice", {
16
+ readonly loop: Schema.String;
17
+ readonly check: Schema.String;
18
+ readonly step: Schema.String;
19
+ }>, Cause.YieldableError>;
20
+ export declare class StepNamedTwice extends StepNamedTwice_base {
21
+ get detail(): string;
22
+ get message(): string;
23
+ }
24
+ declare const ReplayDiverged_base: Schema.Class<ReplayDiverged, Schema.TaggedStruct<"ReplayDiverged", {
25
+ readonly loop: Schema.String;
26
+ readonly check: Schema.String;
27
+ readonly first: Schema.$Array<Schema.String>;
28
+ readonly replay: Schema.$Array<Schema.String>;
29
+ readonly rerun: Schema.$Array<Schema.String>;
30
+ }>, Cause.YieldableError>;
31
+ export declare class ReplayDiverged extends ReplayDiverged_base {
32
+ get detail(): string;
33
+ get message(): string;
34
+ }
35
+ export declare const LoopCheckError: Schema.Union<readonly [typeof CheckFailed, typeof StepNamedTwice, typeof ReplayDiverged]>;
36
+ export type LoopCheckError = typeof LoopCheckError.Type;
37
+ /** Runs a check twice, the second time from the first run's journal; the replay must take the same Steps and rerun no Activity. */
38
+ export declare const checkLoop: (loop: LoopDefinition<unknown, unknown, unknown>, check: LoopCheck) => Effect.Effect<void, LoopCheckError>;
39
+ export {};
@@ -0,0 +1,68 @@
1
+ import type { KitAssignmentDeclaration, KitInstallationDeclaration, ScheduleDeclaration } from '../../../core/src/package-declarations';
2
+ import type { LoopDefinition } from './define';
3
+ /** Agent instructions inline, or a Markdown file in the Package's repository, read at build. */
4
+ export type AgentInstructions = string | {
5
+ readonly file: string;
6
+ };
7
+ export type AgentConfig = {
8
+ /** The Agent this one extends. */
9
+ readonly extends?: string;
10
+ readonly instructions?: AgentInstructions;
11
+ readonly harness?: string;
12
+ readonly model?: string;
13
+ /** How hard its harness thinks; a harness without the control ignores it. */
14
+ readonly effort?: 'low' | 'medium' | 'high' | 'xhigh';
15
+ /** Kit references. */
16
+ readonly kits?: readonly string[];
17
+ /** Hosts its sandboxed Steps may reach beyond the defaults, or `open` for an Agent that browses. */
18
+ readonly network?: {
19
+ readonly hosts: readonly string[];
20
+ } | 'open';
21
+ /** Runs its Steps only on Runners that run agents in docker, for services or a project image. */
22
+ readonly sandbox?: 'docker';
23
+ };
24
+ /** A Kit written from the Package's files: its context, and skill directories each holding a `SKILL.md`. */
25
+ export type AuthoredKitConfig = {
26
+ readonly name: string;
27
+ readonly kind?: 'technology' | 'brand' | 'domain' | 'process' | 'other';
28
+ readonly description?: string;
29
+ readonly context: AgentInstructions;
30
+ /** Skill directories in the repository; each is named after its directory. */
31
+ readonly skills?: readonly string[];
32
+ };
33
+ /** An authored Kit, a Marketplace Kit to install, or where a Kit applies. */
34
+ export type KitConfig = AuthoredKitConfig | KitInstallationDeclaration | KitAssignmentDeclaration;
35
+ export type PackageLoop = LoopDefinition<unknown, unknown, unknown>;
36
+ /** A Package's `kitman.config.ts` default export. */
37
+ export type PackageConfig = {
38
+ readonly loops: readonly PackageLoop[];
39
+ readonly agents?: {
40
+ readonly [id: string]: AgentConfig;
41
+ };
42
+ readonly schedules?: {
43
+ readonly [key: string]: ScheduleDeclaration;
44
+ };
45
+ readonly kits?: {
46
+ readonly [key: string]: KitConfig;
47
+ };
48
+ };
49
+ /** Each element a Loop, whatever its Input, Output and error types. */
50
+ type Loops<L extends readonly unknown[]> = {
51
+ readonly [K in keyof L]: L[K] extends LoopDefinition<infer In, infer Out, infer E> ? LoopDefinition<In, Out, E> : never;
52
+ };
53
+ /** Declares a Package: its Loops, and its Agents keyed by id. */
54
+ export declare const defineConfig: <const L extends readonly unknown[]>(config: {
55
+ readonly loops: L & Loops<L>;
56
+ readonly agents?: {
57
+ readonly [id: string]: AgentConfig;
58
+ };
59
+ /** Recurring starts of a Loop, keyed; the Package owns each Schedule it declares. */
60
+ readonly schedules?: {
61
+ readonly [key: string]: ScheduleDeclaration;
62
+ };
63
+ /** Kits, keyed; only a Workspace Package may declare them. */
64
+ readonly kits?: {
65
+ readonly [key: string]: KitConfig;
66
+ };
67
+ }) => PackageConfig;
68
+ export {};
@@ -0,0 +1,69 @@
1
+ import { LoopCapabilities, type LoopManifest } from '../../../core/src/package-declarations';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as Schema from 'effect/Schema';
4
+ import type { WorkflowEngine } from 'effect/workflow';
5
+ import type { LoopHost, LoopRun } from './steps';
6
+ import type { LoopCheck } from './test-loop';
7
+ import type { ArtifactActivity, ChangeRequestActivity, CommentActivity, CreateTasksActivity, IntegrationBranchActivity, MergeChangeRequestActivity, NoteActivity, ReleaseActivity, WriteBackActivity } from './activities';
8
+ export { LoopCapabilities, type LoopManifest };
9
+ /** What a Loop's program may ask Kitman for; the control plane checks each request against them. */
10
+ export type LoopCapability = (typeof LoopCapabilities)[number];
11
+ export declare const LoopOutcome: Schema.Literals<readonly ["feature", "bug", "refactor", "investigation", "docs", "migration"]>;
12
+ export type LoopOutcome = typeof LoopOutcome.Type;
13
+ export type LoopCheckout = 'none' | 'read' | 'write';
14
+ type EventFilterValue = string | number | boolean | null;
15
+ /** Matched by the control plane against Event payload paths: a value, or any of several. */
16
+ export type EventFilter = {
17
+ readonly [path: string]: EventFilterValue | readonly EventFilterValue[];
18
+ };
19
+ /** Starts a Run on a matching Event, binding Event payload paths into the Loop Input. */
20
+ export type WhenClause = {
21
+ readonly event: string;
22
+ readonly filter?: EventFilter;
23
+ readonly input: {
24
+ readonly [inputField: string]: string;
25
+ };
26
+ };
27
+ /** An action shown on a settled Run: start another Loop. */
28
+ export type LoopOffer = {
29
+ readonly id: string;
30
+ readonly title: string;
31
+ readonly loop: string;
32
+ };
33
+ /** The services a Loop's program runs with; a Runner or `testLoop` provides them. */
34
+ export type LoopServices = LoopRun | LoopHost | ChangeRequestActivity | WriteBackActivity | ArtifactActivity | NoteActivity | CommentActivity | CreateTasksActivity | IntegrationBranchActivity | MergeChangeRequestActivity | ReleaseActivity | WorkflowEngine.WorkflowEngine | WorkflowEngine.WorkflowInstance;
35
+ /** A schema a Loop can decode and encode with no services. */
36
+ export type LoopSchema<T> = Schema.Codec<T, unknown>;
37
+ export type LoopDefinition<In, Out, E> = {
38
+ readonly id: string;
39
+ readonly title: string;
40
+ readonly input: LoopSchema<In>;
41
+ readonly output: LoopSchema<Out>;
42
+ readonly outcome?: LoopOutcome;
43
+ /** Agent ids by role; `agentWork` names a role. */
44
+ readonly agents: {
45
+ readonly [role: string]: string;
46
+ };
47
+ readonly checkout: LoopCheckout;
48
+ readonly when?: readonly WhenClause[];
49
+ readonly offers?: readonly LoopOffer[];
50
+ readonly capabilities: readonly LoopCapability[];
51
+ /** The Secrets the program reads with `Config.Redacted`, and `agentWork` may put into a Step's sandbox. */
52
+ readonly secrets?: readonly string[];
53
+ readonly run: (input: In) => Effect.Effect<Out, E, LoopServices>;
54
+ /** Scripts a build runs twice, the second time from the journal; not part of the manifest. */
55
+ readonly checks?: readonly LoopCheck[];
56
+ };
57
+ /** A Loop module's default export. The definition keeps its shape, so a fork spreads it. */
58
+ export declare const defineLoop: <In, Out, E>(definition: LoopDefinition<In, Out, E>) => LoopDefinition<In, Out, E>;
59
+ declare const ManifestInvalid_base: Schema.Class<ManifestInvalid, Schema.TaggedStruct<"ManifestInvalid", {
60
+ readonly loop: Schema.String;
61
+ readonly message: Schema.String;
62
+ }>, import("effect/Cause").YieldableError>;
63
+ export declare class ManifestInvalid extends ManifestInvalid_base {
64
+ }
65
+ export declare const jsonSchemaOf: <T>(loop: string, schema: LoopSchema<T>) => Effect.Effect<{
66
+ readonly [x: string]: Schema.Json;
67
+ }, ManifestInvalid, never>;
68
+ /** The data the control plane reads from a Loop, made without calling `run`. */
69
+ export declare const loopManifest: <In, Out, E>(definition: LoopDefinition<In, Out, E>) => Effect.Effect<LoopManifest, ManifestInvalid>;
@@ -0,0 +1,66 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import type { LoopOutcome } from './define';
3
+ import type { ScopeJudgement } from './review';
4
+ /** One approved verification's result at a tree, as a Runner recorded it. */
5
+ export declare const EvidenceCheck: Schema.Struct<{
6
+ readonly name: Schema.String;
7
+ readonly command: Schema.String;
8
+ readonly status: Schema.Literals<readonly ["passed", "failed"]>;
9
+ /** It also fails on the default branch's head, so the Run did not cause it. */
10
+ readonly preExisting: Schema.Boolean;
11
+ readonly durationMs: Schema.Finite;
12
+ readonly evidenceId: Schema.String;
13
+ }>;
14
+ export type EvidenceCheck = typeof EvidenceCheck.Type;
15
+ /** Evidence for a revision; `tree` is its git tree id, and the evidence holds for any revision with that tree. */
16
+ export declare const VerifyResult: Schema.Struct<{
17
+ readonly revision: Schema.String;
18
+ readonly tree: Schema.String;
19
+ /** Every check passed or already failed on the default branch. */
20
+ readonly passed: Schema.Boolean;
21
+ readonly checks: Schema.$Array<Schema.Struct<{
22
+ readonly name: Schema.String;
23
+ readonly command: Schema.String;
24
+ readonly status: Schema.Literals<readonly ["passed", "failed"]>;
25
+ /** It also fails on the default branch's head, so the Run did not cause it. */
26
+ readonly preExisting: Schema.Boolean;
27
+ readonly durationMs: Schema.Finite;
28
+ readonly evidenceId: Schema.String;
29
+ }>>;
30
+ }>;
31
+ export type VerifyResult = typeof VerifyResult.Type;
32
+ /** What closes a Run, by its Outcome; `none` is a Run with no Outcome. */
33
+ export declare const OutcomeTable: {
34
+ readonly feature: 'Approved verifications pass on the head tree, and review says the scope was met';
35
+ readonly bug: 'A reproducing check fails on the base and passes on the head';
36
+ readonly refactor: 'Approved verifications pass on both base and head';
37
+ readonly investigation: 'A conclusion Output with its sources; no patch needed';
38
+ readonly docs: 'The documented commands run';
39
+ readonly migration: 'A rollback check passes';
40
+ readonly none: 'Only the approved verifications';
41
+ };
42
+ export type EvidenceGateInput = {
43
+ readonly outcome?: LoopOutcome;
44
+ readonly head?: VerifyResult;
45
+ readonly base?: VerifyResult;
46
+ /** The reviewer's scope judgement; absent when no reviewer judged it, which never reads as met. */
47
+ readonly review?: ScopeJudgement;
48
+ /** The check that reproduces a bug. */
49
+ readonly reproducing?: string;
50
+ readonly conclusion?: {
51
+ readonly text: string;
52
+ readonly sources: readonly string[];
53
+ };
54
+ /** The checks that run the documented commands. */
55
+ readonly documented?: readonly string[];
56
+ /** The check that rolls a migration back. */
57
+ readonly rollback?: string;
58
+ };
59
+ export type EvidenceVerdict = {
60
+ readonly settled: true;
61
+ } | {
62
+ readonly settled: false;
63
+ readonly reasons: readonly string[];
64
+ };
65
+ /** Whether the Run's evidence closes its Outcome, per `OutcomeTable`; claims in Outputs never count. */
66
+ export declare const evidenceGate: (input: EvidenceGateInput) => EvidenceVerdict;
@@ -0,0 +1,9 @@
1
+ export * from './define';
2
+ export * from './steps';
3
+ export * from './activities';
4
+ export * from './test-loop';
5
+ export * from './evidence';
6
+ export * from './review';
7
+ export * from './plan';
8
+ export * from './check';
9
+ export * from './config';
@@ -0,0 +1,43 @@
1
+ import * as Effect from 'effect/Effect';
2
+ import * as Schema from 'effect/Schema';
3
+ /** One unit of a plan, which Implement now turns into a Task and builds. */
4
+ export declare const PlanTicket: Schema.Struct<{
5
+ /** Short and unique within the plan; blockers name it. */
6
+ readonly key: Schema.String;
7
+ readonly title: Schema.String;
8
+ readonly body: Schema.String;
9
+ readonly acceptanceCriteria: Schema.$Array<Schema.String>;
10
+ /** The repository it changes; the Project's default when left out. */
11
+ readonly repoBindingId: Schema.optional<Schema.String>;
12
+ /** Keys of the tickets that must be built first. */
13
+ readonly blockedBy: Schema.$Array<Schema.String>;
14
+ /** The kind of change; its Task gets the first Task Type with this Outcome. */
15
+ readonly outcome: Schema.optional<Schema.Literals<readonly ["feature", "bug", "refactor", "investigation", "docs", "migration"]>>;
16
+ }>;
17
+ export type PlanTicket = typeof PlanTicket.Type;
18
+ /** A plan's tickets; a blocker must name another ticket, and no tickets may block each other in a cycle. */
19
+ export declare const PlanTickets: Schema.$Array<Schema.Struct<{
20
+ /** Short and unique within the plan; blockers name it. */
21
+ readonly key: Schema.String;
22
+ readonly title: Schema.String;
23
+ readonly body: Schema.String;
24
+ readonly acceptanceCriteria: Schema.$Array<Schema.String>;
25
+ /** The repository it changes; the Project's default when left out. */
26
+ readonly repoBindingId: Schema.optional<Schema.String>;
27
+ /** Keys of the tickets that must be built first. */
28
+ readonly blockedBy: Schema.$Array<Schema.String>;
29
+ /** The kind of change; its Task gets the first Task Type with this Outcome. */
30
+ readonly outcome: Schema.optional<Schema.Literals<readonly ["feature", "bug", "refactor", "investigation", "docs", "migration"]>>;
31
+ }>>;
32
+ declare const BlockingCycle_base: Schema.Class<BlockingCycle, Schema.TaggedStruct<"BlockingCycle", {
33
+ readonly tickets: Schema.$Array<Schema.String>;
34
+ }>, import("effect/Cause").YieldableError>;
35
+ export declare class BlockingCycle extends BlockingCycle_base {
36
+ get message(): string;
37
+ }
38
+ /**
39
+ * Orders tickets into waves: a ticket is in the wave after its last blocker's, and each wave is grouped by
40
+ * RepoBinding. Every ticket in a wave can be built at once.
41
+ */
42
+ export declare const planWaves: (tickets: readonly PlanTicket[]) => Effect.Effect<readonly PlanTicket[][], BlockingCycle>;
43
+ export {};
@@ -0,0 +1,86 @@
1
+ import * as Schema from 'effect/Schema';
2
+ export declare const Severity: Schema.Literals<readonly ["blocker", "major", "minor"]>;
3
+ export type Severity = typeof Severity.Type;
4
+ /** What one reviewer seat found. */
5
+ export declare const Finding: Schema.Struct<{
6
+ readonly severity: Schema.Literals<readonly ["blocker", "major", "minor"]>;
7
+ readonly file: Schema.String;
8
+ readonly line: Schema.Int;
9
+ readonly detail: Schema.String;
10
+ }>;
11
+ export type Finding = typeof Finding.Type;
12
+ /** A finding after the panel's findings are merged; `id` is its file and line. */
13
+ export declare const MergedFinding: Schema.Struct<{
14
+ readonly severity: Schema.Literals<readonly ["blocker", "major", "minor"]>;
15
+ readonly file: Schema.String;
16
+ readonly line: Schema.Int;
17
+ readonly detail: Schema.String;
18
+ readonly id: Schema.String;
19
+ readonly seats: Schema.$Array<Schema.String>;
20
+ }>;
21
+ export type MergedFinding = typeof MergedFinding.Type;
22
+ export declare const Rebuttal: Schema.Struct<{
23
+ readonly findingId: Schema.String;
24
+ readonly reason: Schema.String;
25
+ }>;
26
+ export type Rebuttal = typeof Rebuttal.Type;
27
+ export declare const RebuttalVerdict: Schema.Struct<{
28
+ readonly findingId: Schema.String;
29
+ readonly accepted: Schema.Boolean;
30
+ }>;
31
+ export type RebuttalVerdict = typeof RebuttalVerdict.Type;
32
+ /** Whether a change does what its Task asks; `unmet` names each criterion or part of the description not done. */
33
+ export declare const ScopeJudgement: Schema.Struct<{
34
+ readonly met: Schema.Boolean;
35
+ readonly unmet: Schema.$Array<Schema.String>;
36
+ }>;
37
+ export type ScopeJudgement = typeof ScopeJudgement.Type;
38
+ export type Disputed = {
39
+ readonly finding: MergedFinding;
40
+ readonly rebuttal: Rebuttal;
41
+ };
42
+ export declare const isBlocking: (finding: Pick<Finding, 'severity'>) => boolean;
43
+ /** One finding per file and line; the worst severity's detail wins, and every seat that raised it is kept. */
44
+ export declare const mergeFindings: (bySeat: {
45
+ readonly [seat: string]: readonly Finding[];
46
+ }) => readonly MergedFinding[];
47
+ export declare const splitDisputed: (findings: readonly MergedFinding[], rebuttals: readonly Rebuttal[]) => {
48
+ disputed: Disputed[];
49
+ undisputed: {
50
+ readonly severity: "blocker" | "major" | "minor";
51
+ readonly file: string;
52
+ readonly line: number;
53
+ readonly detail: string;
54
+ readonly id: string;
55
+ readonly seats: readonly string[];
56
+ }[];
57
+ };
58
+ export type SettledRound = {
59
+ /** Findings still to fix. */
60
+ readonly open: readonly MergedFinding[];
61
+ /** Rebutted, and the reviewers accepted the rebuttal. */
62
+ readonly withdrawn: readonly Disputed[];
63
+ /** Rebutted, and the reviewers did not accept the rebuttal. */
64
+ readonly standing: readonly Disputed[];
65
+ };
66
+ /** A rebutted finding is withdrawn only when every verdict on it accepts the rebuttal. */
67
+ export declare const settleRound: (round: {
68
+ readonly findings: readonly MergedFinding[];
69
+ readonly rebuttals: readonly Rebuttal[];
70
+ readonly verdicts: readonly RebuttalVerdict[];
71
+ }) => SettledRound;
72
+ export type RallyStopReason = 'settled' | 'dispute_stands' | 'findings_returned' | 'round_cap';
73
+ export type RallyDecision = {
74
+ readonly stop: false;
75
+ } | {
76
+ readonly stop: true;
77
+ readonly reason: RallyStopReason;
78
+ readonly unsettled: readonly string[];
79
+ };
80
+ /** Whether the rally ends after this round; `previous` is the last round's blocking finding ids. */
81
+ export declare const rallyStop: (input: {
82
+ readonly round: number;
83
+ readonly maxRounds: number;
84
+ readonly settled: SettledRound;
85
+ readonly previous?: readonly string[];
86
+ }) => RallyDecision;
@@ -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 {};