@hasna/loops 0.3.60 → 0.4.1
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/CHANGELOG.md +265 -0
- package/LICENSE +197 -13
- package/README.md +95 -85
- package/dist/api/index.d.ts +11 -0
- package/dist/api/index.js +333 -0
- package/dist/cli/index.js +8013 -6659
- package/dist/daemon/control.d.ts +21 -1
- package/dist/daemon/daemon.d.ts +5 -0
- package/dist/daemon/index.js +2836 -1222
- package/dist/daemon/install.d.ts +1 -1
- package/dist/index.d.ts +23 -8
- package/dist/index.js +5715 -4541
- package/dist/lib/accounts.d.ts +6 -1
- package/dist/lib/agent-adapter.d.ts +74 -0
- package/dist/lib/backup.d.ts +25 -0
- package/dist/lib/errors.d.ts +21 -0
- package/dist/lib/executor.d.ts +10 -1
- package/dist/lib/goal/metadata.d.ts +16 -0
- package/dist/lib/goal/model-factory.d.ts +1 -0
- package/dist/lib/goal/prompts.d.ts +3 -1
- package/dist/lib/goal/types.d.ts +3 -0
- package/dist/lib/health.d.ts +1 -1
- package/dist/lib/ids.d.ts +8 -1
- package/dist/lib/machines.d.ts +6 -0
- package/dist/lib/mode.d.ts +48 -0
- package/dist/lib/mode.js +260 -0
- package/dist/lib/process-identity.d.ts +16 -0
- package/dist/lib/{schedule.d.ts → recurrence.d.ts} +1 -0
- package/dist/lib/redact.d.ts +21 -0
- package/dist/lib/route/cursors.d.ts +18 -0
- package/dist/lib/route/drain.d.ts +6 -0
- package/dist/lib/route/fields.d.ts +27 -0
- package/dist/lib/route/gates.d.ts +26 -0
- package/dist/lib/route/index.d.ts +18 -0
- package/dist/lib/route/options.d.ts +31 -0
- package/dist/lib/route/parse.d.ts +8 -0
- package/dist/lib/route/pr-review.d.ts +11 -0
- package/dist/lib/route/provider.d.ts +41 -0
- package/dist/lib/route/route-event.d.ts +23 -0
- package/dist/lib/route/route-tasks.d.ts +75 -0
- package/dist/lib/route/throttle.d.ts +47 -0
- package/dist/lib/route/todos-cli.d.ts +21 -0
- package/dist/lib/route/types.d.ts +88 -0
- package/dist/lib/run-artifacts.d.ts +17 -2
- package/dist/lib/run-envelope.d.ts +41 -0
- package/dist/lib/scheduler.d.ts +78 -2
- package/dist/lib/store.d.ts +63 -0
- package/dist/lib/store.js +1007 -287
- package/dist/lib/template-kit.d.ts +70 -0
- package/dist/lib/templates-custom.d.ts +34 -0
- package/dist/lib/templates.d.ts +13 -81
- package/dist/lib/workflow-runner.d.ts +2 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.js +3231 -1382
- package/dist/runner/index.d.ts +9 -0
- package/dist/runner/index.js +295 -0
- package/dist/sdk/index.d.ts +29 -3
- package/dist/sdk/index.js +2743 -1044
- package/dist/test-helpers.d.ts +37 -0
- package/dist/types.d.ts +3 -1
- package/docs/DEPLOYMENT_MODES.md +140 -0
- package/docs/USAGE.md +102 -46
- package/package.json +23 -5
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { AgentWorktreeSpec, LoopTemplateSummary } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Builtin template metadata, prompt kit, and deterministic script assets.
|
|
4
|
+
*
|
|
5
|
+
* The copy-edited prose blocks (worktree policy, exact-todos-commands stanzas,
|
|
6
|
+
* evidence rules, no-tmux stanzas) live here as composable named fragments;
|
|
7
|
+
* per-template wording deltas are explicit parameters so drift stays visible
|
|
8
|
+
* in one place. Rendered wording is contract-tested in templates.test.ts.
|
|
9
|
+
*/
|
|
10
|
+
export declare const TODOS_TASK_WORKER_VERIFIER_TEMPLATE_ID = "todos-task-worker-verifier";
|
|
11
|
+
export declare const EVENT_WORKER_VERIFIER_TEMPLATE_ID = "event-worker-verifier";
|
|
12
|
+
export declare const BOUNDED_AGENT_WORKER_VERIFIER_TEMPLATE_ID = "bounded-agent-worker-verifier";
|
|
13
|
+
export declare const TASK_LIFECYCLE_TEMPLATE_ID = "task-lifecycle";
|
|
14
|
+
export declare const PR_REVIEW_TEMPLATE_ID = "pr-review";
|
|
15
|
+
export declare const SCHEDULED_AUDIT_TEMPLATE_ID = "scheduled-audit";
|
|
16
|
+
export declare const KNOWLEDGE_REFRESH_TEMPLATE_ID = "knowledge-refresh";
|
|
17
|
+
export declare const REPORT_ONLY_TEMPLATE_ID = "report-only";
|
|
18
|
+
export declare const INCIDENT_RESPONSE_TEMPLATE_ID = "incident-response";
|
|
19
|
+
export declare const DETERMINISTIC_CHECK_CREATE_TASK_TEMPLATE_ID = "deterministic-check-create-task";
|
|
20
|
+
export type AgentWorkflowRole = "triage" | "planner" | "worker" | "verifier";
|
|
21
|
+
export declare const BUILTIN_TEMPLATE_SUMMARIES: LoopTemplateSummary[];
|
|
22
|
+
export declare const NO_TMUX_DISPATCH_FRAGMENT = "Do not dispatch or paste prompts into tmux panes. If additional work is required, create or update deduped todos tasks so task-created routing can start a fresh headless workflow.";
|
|
23
|
+
export declare const WORKER_LEAVES_COMPLETION_FRAGMENT = "Do not mark the task complete in the worker step; the verifier step owns completion after independent validation.";
|
|
24
|
+
export declare const VERIFIER_TINY_FIXES_FRAGMENT = "Do not make broad unrelated changes. Only apply tiny verification fixes when they are necessary and low risk; otherwise create follow-up tasks.";
|
|
25
|
+
export declare const TASK_VERIFIER_DECISION_FRAGMENT = "If the work is valid, record verification evidence in todos and mark/leave the task in the correct completed state according to the todos CLI. If it is not valid, add precise follow-up tasks or comments and leave the original task open or blocked with clear evidence.";
|
|
26
|
+
export declare const LIFECYCLE_VERIFIER_DECISION_FRAGMENT = "If the work is valid, record verification evidence in todos and mark/leave the task completed according to the todos CLI. If not valid, add precise follow-up tasks or comments and leave the original task open or blocked with clear evidence.";
|
|
27
|
+
export declare const EVENT_VERIFIER_DECISION_FRAGMENT = "If the work is valid, record verification evidence in the relevant local system. If it is not valid, add precise follow-up tasks/comments and leave the event handling state open or blocked with clear evidence.";
|
|
28
|
+
export declare const BOUNDED_VERIFIER_REVIEW_FRAGMENT = "Use fresh context. Review the worker result for correctness, regressions, missing tests, safety, runaway-agent risk, output bounds, and incomplete evidence.";
|
|
29
|
+
export declare const BOUNDED_VERIFIER_DECISION_FRAGMENT = "If valid, record verification evidence. If invalid, create precise follow-up tasks or comments and leave the original work open. Do not make broad unrelated changes.";
|
|
30
|
+
export declare const TASK_REVIEW_FOCUS = "correctness, regressions, missing tests, security, and incomplete requirements";
|
|
31
|
+
export declare const EVENT_REVIEW_FOCUS = "correctness, regressions, security, missing evidence, and incomplete requirements";
|
|
32
|
+
export type BuiltinFlow = "task" | "lifecycle" | "event" | "bounded";
|
|
33
|
+
export declare function roleFragment(role: string, flow: BuiltinFlow): string;
|
|
34
|
+
/**
|
|
35
|
+
* `/goal` header lines. The blank separator line is intentionally part of the
|
|
36
|
+
* fragment; prompts assembled with `.filter(Boolean)` historically drop it and
|
|
37
|
+
* that rendering is contract-tested, so composition must preserve both shapes.
|
|
38
|
+
*/
|
|
39
|
+
export declare function goalHeaderFragment(goal: string, role: string, flow: BuiltinFlow): string[];
|
|
40
|
+
export declare function adversarialReviewFragment(inspect: string, focus: string): string;
|
|
41
|
+
export declare const DEFAULT_VERIFIER_IDLE_TIMEOUT_MS: number;
|
|
42
|
+
export declare function verifierIdleTimeoutMs(input: {
|
|
43
|
+
verifierIdleTimeoutMs?: number;
|
|
44
|
+
}): number | undefined;
|
|
45
|
+
export declare function verifierRuntimeGuidance(input: {
|
|
46
|
+
verifierIdleTimeoutMs?: number;
|
|
47
|
+
}): string;
|
|
48
|
+
export declare function todosInspectLine(todosProjectPath: string, taskId: string): string;
|
|
49
|
+
export declare function todosStartLine(todosProjectPath: string, taskId: string): string;
|
|
50
|
+
export declare function todosEvidenceLine(todosProjectPath: string, taskId: string, placeholder: string): string;
|
|
51
|
+
export declare function todosVerificationLine(todosProjectPath: string, taskId: string): string;
|
|
52
|
+
export declare function todosDoneLine(todosProjectPath: string, taskId: string): string;
|
|
53
|
+
/** Exact-todos-commands stanza: project pin, cwd-inference warning, inspect, then role-specific command lines. */
|
|
54
|
+
export declare function todosExactCommandsFragment(todosProjectPath: string, taskId: string, commandLines: string[]): string[];
|
|
55
|
+
/** Worktree policy PROSE for agent guidance; enforcement is executor-native via target.worktree. */
|
|
56
|
+
export declare function worktreePrompt(plan: AgentWorktreeSpec): string;
|
|
57
|
+
export declare function worktreeContextFragment(plan: AgentWorktreeSpec): Record<string, unknown>;
|
|
58
|
+
export declare function shellQuote(value: string): string;
|
|
59
|
+
export declare function sourceTaskGateCommand(todosProjectPath: string, taskId: string): string;
|
|
60
|
+
export type LifecycleGateStage = "triage" | "planner";
|
|
61
|
+
export declare function lifecycleGateCommand(todosProjectPath: string, taskId: string, stage: LifecycleGateStage, goMarker: string, blockedMarker: string): string;
|
|
62
|
+
export interface PrHandoffCommandOptions {
|
|
63
|
+
artifactPath: string;
|
|
64
|
+
taskId: string;
|
|
65
|
+
todosProjectPath: string;
|
|
66
|
+
worktreeCwd: string;
|
|
67
|
+
worktreeRoot: string;
|
|
68
|
+
expectedBranch: string;
|
|
69
|
+
}
|
|
70
|
+
export declare function prHandoffCommand(opts: PrHandoffCommandOptions): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CreateWorkflowInput, LoopTemplateSummary, LoopTemplateVariable } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Custom loop template registry: JSON-defined workflow templates stored under
|
|
4
|
+
* the data dir. Rendering fails closed on danger-full-access/bypass flags and
|
|
5
|
+
* on collisions with the builtin template keys (passed in as reservedKeys).
|
|
6
|
+
*/
|
|
7
|
+
export interface CustomLoopTemplateImportOptions {
|
|
8
|
+
replace?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface CustomLoopTemplateImportResult {
|
|
11
|
+
template: LoopTemplateSummary;
|
|
12
|
+
path: string;
|
|
13
|
+
replaced: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface CustomLoopTemplateDefinition {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
kind: "workflow";
|
|
20
|
+
variables: LoopTemplateVariable[];
|
|
21
|
+
workflow: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface CustomLoopTemplateEntry {
|
|
24
|
+
definition: CustomLoopTemplateDefinition;
|
|
25
|
+
summary: LoopTemplateSummary;
|
|
26
|
+
path: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function customLoopTemplatesDir(): string;
|
|
29
|
+
export declare function loadCustomLoopTemplates(reservedKeys: Set<string>): CustomLoopTemplateEntry[];
|
|
30
|
+
export declare function getCustomLoopTemplate(id: string, reservedKeys: Set<string>): CustomLoopTemplateEntry | undefined;
|
|
31
|
+
export declare function renderCustomLoopTemplate(entry: CustomLoopTemplateEntry, values: Record<string, string | undefined>): CreateWorkflowInput;
|
|
32
|
+
export declare function validateCustomLoopTemplateFile(file: string, reservedKeys: Set<string>): LoopTemplateSummary;
|
|
33
|
+
export declare function importCustomLoopTemplate(file: string, reservedKeys: Set<string>, opts?: CustomLoopTemplateImportOptions): CustomLoopTemplateImportResult;
|
|
34
|
+
export {};
|
package/dist/lib/templates.d.ts
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import type { AccountRef, AgentPermissionMode, AgentProvider, AgentSandbox, AgentWorktreeMode, CreateWorkflowInput, LoopTemplateSource, LoopTemplateSummary, TimeoutMs } from "../types.js";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
export declare const SCHEDULED_AUDIT_TEMPLATE_ID = "scheduled-audit";
|
|
8
|
-
export declare const KNOWLEDGE_REFRESH_TEMPLATE_ID = "knowledge-refresh";
|
|
9
|
-
export declare const REPORT_ONLY_TEMPLATE_ID = "report-only";
|
|
10
|
-
export declare const INCIDENT_RESPONSE_TEMPLATE_ID = "incident-response";
|
|
11
|
-
export declare const DETERMINISTIC_CHECK_CREATE_TASK_TEMPLATE_ID = "deterministic-check-create-task";
|
|
12
|
-
export interface TodosTaskWorkflowTemplateInput {
|
|
13
|
-
taskId: string;
|
|
14
|
-
taskTitle?: string;
|
|
15
|
-
taskDescription?: string;
|
|
2
|
+
export { BOUNDED_AGENT_WORKER_VERIFIER_TEMPLATE_ID, DETERMINISTIC_CHECK_CREATE_TASK_TEMPLATE_ID, EVENT_WORKER_VERIFIER_TEMPLATE_ID, INCIDENT_RESPONSE_TEMPLATE_ID, KNOWLEDGE_REFRESH_TEMPLATE_ID, PR_REVIEW_TEMPLATE_ID, REPORT_ONLY_TEMPLATE_ID, SCHEDULED_AUDIT_TEMPLATE_ID, TASK_LIFECYCLE_TEMPLATE_ID, TODOS_TASK_WORKER_VERIFIER_TEMPLATE_ID, } from "./template-kit.js";
|
|
3
|
+
import type { CustomLoopTemplateImportOptions, CustomLoopTemplateImportResult } from "./templates-custom.js";
|
|
4
|
+
export type { CustomLoopTemplateImportOptions, CustomLoopTemplateImportResult } from "./templates-custom.js";
|
|
5
|
+
/** Agent/account/worktree fields shared by every agent-backed builtin template input. */
|
|
6
|
+
export interface AgentWorkflowTemplateBaseInput {
|
|
16
7
|
projectPath: string;
|
|
17
|
-
todosProjectPath?: string;
|
|
18
8
|
routeProjectPath?: string;
|
|
19
9
|
projectGroup?: string;
|
|
20
10
|
provider?: AgentProvider;
|
|
@@ -42,91 +32,33 @@ export interface TodosTaskWorkflowTemplateInput {
|
|
|
42
32
|
worktreeBranchPrefix?: string;
|
|
43
33
|
timeoutMs?: TimeoutMs;
|
|
44
34
|
verifierIdleTimeoutMs?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface TodosTaskWorkflowTemplateInput extends AgentWorkflowTemplateBaseInput {
|
|
37
|
+
taskId: string;
|
|
38
|
+
taskTitle?: string;
|
|
39
|
+
taskDescription?: string;
|
|
40
|
+
todosProjectPath?: string;
|
|
45
41
|
prHandoff?: boolean;
|
|
46
42
|
eventId?: string;
|
|
47
43
|
eventType?: string;
|
|
48
44
|
}
|
|
49
|
-
export interface EventWorkflowTemplateInput {
|
|
45
|
+
export interface EventWorkflowTemplateInput extends AgentWorkflowTemplateBaseInput {
|
|
50
46
|
eventId: string;
|
|
51
47
|
eventType: string;
|
|
52
48
|
eventSource: string;
|
|
53
49
|
eventSubject?: string;
|
|
54
50
|
eventMessage?: string;
|
|
55
51
|
eventJson: string;
|
|
56
|
-
projectPath: string;
|
|
57
|
-
routeProjectPath?: string;
|
|
58
|
-
projectGroup?: string;
|
|
59
|
-
provider?: AgentProvider;
|
|
60
|
-
authProfile?: string;
|
|
61
|
-
authProfilePool?: string[];
|
|
62
|
-
triageAuthProfile?: string;
|
|
63
|
-
plannerAuthProfile?: string;
|
|
64
|
-
workerAuthProfile?: string;
|
|
65
|
-
verifierAuthProfile?: string;
|
|
66
|
-
account?: AccountRef;
|
|
67
|
-
accountPool?: AccountRef[];
|
|
68
|
-
triageAccount?: AccountRef;
|
|
69
|
-
plannerAccount?: AccountRef;
|
|
70
|
-
workerAccount?: AccountRef;
|
|
71
|
-
verifierAccount?: AccountRef;
|
|
72
|
-
model?: string;
|
|
73
|
-
variant?: string;
|
|
74
|
-
agent?: string;
|
|
75
|
-
addDirs?: string[];
|
|
76
|
-
permissionMode?: AgentPermissionMode;
|
|
77
|
-
sandbox?: AgentSandbox;
|
|
78
|
-
manualBreakGlass?: boolean;
|
|
79
|
-
worktreeMode?: AgentWorktreeMode;
|
|
80
|
-
worktreeRoot?: string;
|
|
81
|
-
worktreeBranchPrefix?: string;
|
|
82
|
-
timeoutMs?: TimeoutMs;
|
|
83
|
-
verifierIdleTimeoutMs?: number;
|
|
84
52
|
}
|
|
85
|
-
export interface BoundedAgentWorkflowTemplateInput {
|
|
53
|
+
export interface BoundedAgentWorkflowTemplateInput extends AgentWorkflowTemplateBaseInput {
|
|
86
54
|
name?: string;
|
|
87
55
|
objective: string;
|
|
88
56
|
prompt?: string;
|
|
89
|
-
projectPath: string;
|
|
90
|
-
routeProjectPath?: string;
|
|
91
|
-
projectGroup?: string;
|
|
92
|
-
provider?: AgentProvider;
|
|
93
|
-
authProfile?: string;
|
|
94
|
-
authProfilePool?: string[];
|
|
95
|
-
triageAuthProfile?: string;
|
|
96
|
-
plannerAuthProfile?: string;
|
|
97
|
-
workerAuthProfile?: string;
|
|
98
|
-
verifierAuthProfile?: string;
|
|
99
|
-
account?: AccountRef;
|
|
100
|
-
accountPool?: AccountRef[];
|
|
101
|
-
triageAccount?: AccountRef;
|
|
102
|
-
plannerAccount?: AccountRef;
|
|
103
|
-
workerAccount?: AccountRef;
|
|
104
|
-
verifierAccount?: AccountRef;
|
|
105
|
-
model?: string;
|
|
106
|
-
variant?: string;
|
|
107
|
-
agent?: string;
|
|
108
|
-
addDirs?: string[];
|
|
109
|
-
permissionMode?: AgentPermissionMode;
|
|
110
|
-
sandbox?: AgentSandbox;
|
|
111
|
-
manualBreakGlass?: boolean;
|
|
112
|
-
worktreeMode?: AgentWorktreeMode;
|
|
113
|
-
worktreeRoot?: string;
|
|
114
|
-
worktreeBranchPrefix?: string;
|
|
115
|
-
timeoutMs?: TimeoutMs;
|
|
116
|
-
verifierIdleTimeoutMs?: number;
|
|
117
57
|
}
|
|
118
58
|
export type LoopTemplateSourceFilter = LoopTemplateSource | "all";
|
|
119
59
|
export interface ListLoopTemplatesOptions {
|
|
120
60
|
source?: LoopTemplateSourceFilter;
|
|
121
61
|
}
|
|
122
|
-
export interface CustomLoopTemplateImportOptions {
|
|
123
|
-
replace?: boolean;
|
|
124
|
-
}
|
|
125
|
-
export interface CustomLoopTemplateImportResult {
|
|
126
|
-
template: LoopTemplateSummary;
|
|
127
|
-
path: string;
|
|
128
|
-
replaced: boolean;
|
|
129
|
-
}
|
|
130
62
|
export declare function loopTemplatesDir(): string;
|
|
131
63
|
export declare function validateCustomLoopTemplateFile(file: string): LoopTemplateSummary;
|
|
132
64
|
export declare function importCustomLoopTemplate(file: string, opts?: CustomLoopTemplateImportOptions): CustomLoopTemplateImportResult;
|
|
@@ -8,6 +8,8 @@ export interface ExecuteWorkflowOptions extends ExecuteOptions {
|
|
|
8
8
|
idempotencyKey?: string;
|
|
9
9
|
cancelPollMs?: number;
|
|
10
10
|
signalTimeoutMessage?: () => string | undefined;
|
|
11
|
+
/** Per-node goal prompt appended to agent step prompts when a goal executes this workflow. */
|
|
12
|
+
goalNodePrompt?: string;
|
|
11
13
|
}
|
|
12
14
|
export declare function executeWorkflow(store: Store, workflow: WorkflowSpec, opts?: ExecuteWorkflowOptions): Promise<ExecutorResult>;
|
|
13
15
|
export declare function preflightWorkflow(workflow: WorkflowSpec, opts?: ExecuteOptions): ReturnType<typeof preflightTarget>[];
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
export interface LoopsMcpToolMetadata {
|
|
4
4
|
name: string;
|
|
5
|
+
/** legacy tool names kept as deprecated alias registrations */
|
|
6
|
+
aliases?: string[];
|
|
5
7
|
description: string;
|
|
6
8
|
readOnly: boolean;
|
|
7
9
|
guarded?: boolean;
|
|
8
10
|
requiresEnv?: string;
|
|
9
11
|
}
|
|
12
|
+
/** Tool metadata derived from TOOL_REGISTRATIONS; served via loops://tools and `loops mcp list-tools`. */
|
|
10
13
|
export declare const LOOPS_MCP_TOOLS: LoopsMcpToolMetadata[];
|
|
11
14
|
export declare function createLoopsMcpServer(): McpServer;
|
|
12
15
|
export declare function listToolsForCli(): LoopsMcpToolMetadata[];
|