@obversa/runtime 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +192 -0
- package/dist/api.d.ts +72 -0
- package/dist/api.js +9775 -0
- package/dist/api.js.map +1 -0
- package/dist/artifacts/conformance.d.ts +1 -0
- package/dist/artifacts/file-store.d.ts +8 -0
- package/dist/artifacts/store.d.ts +1 -0
- package/dist/callback/approval.d.ts +8 -0
- package/dist/callback/client.d.ts +38 -0
- package/dist/callback/gate.d.ts +1 -0
- package/dist/callback/stored-client.d.ts +5 -0
- package/dist/chunk-3L6YNPN6.js +3 -0
- package/dist/chunk-3L6YNPN6.js.map +1 -0
- package/dist/chunk-5GLEABOU.js +3 -0
- package/dist/chunk-5GLEABOU.js.map +1 -0
- package/dist/chunk-DEW5R23M.js +338 -0
- package/dist/chunk-DEW5R23M.js.map +1 -0
- package/dist/chunk-DV5P4QLI.js +3056 -0
- package/dist/chunk-DV5P4QLI.js.map +1 -0
- package/dist/chunk-NIBHM5I5.js +34 -0
- package/dist/chunk-NIBHM5I5.js.map +1 -0
- package/dist/chunk-RZLMX3IA.js +368 -0
- package/dist/chunk-RZLMX3IA.js.map +1 -0
- package/dist/core/agent-md.d.ts +36 -0
- package/dist/core/agent.d.ts +86 -0
- package/dist/core/approval-job.d.ts +43 -0
- package/dist/core/assert-graph.d.ts +34 -0
- package/dist/core/budget.d.ts +49 -0
- package/dist/core/concurrency.d.ts +2 -0
- package/dist/core/condition.d.ts +209 -0
- package/dist/core/context.d.ts +36 -0
- package/dist/core/cost.d.ts +59 -0
- package/dist/core/dag.d.ts +20 -0
- package/dist/core/decision.d.ts +29 -0
- package/dist/core/describe.d.ts +56 -0
- package/dist/core/engine-meta.d.ts +5 -0
- package/dist/core/env-overlay.d.ts +35 -0
- package/dist/core/errors.d.ts +46 -0
- package/dist/core/feedback.d.ts +68 -0
- package/dist/core/git.d.ts +152 -0
- package/dist/core/guards.d.ts +70 -0
- package/dist/core/isolated.d.ts +40 -0
- package/dist/core/job.d.ts +134 -0
- package/dist/core/limits.d.ts +22 -0
- package/dist/core/loop.d.ts +24 -0
- package/dist/core/merge.d.ts +30 -0
- package/dist/core/pipeline.d.ts +35 -0
- package/dist/core/process.d.ts +11 -0
- package/dist/core/progress.d.ts +82 -0
- package/dist/core/redact.d.ts +1 -0
- package/dist/core/stats.d.ts +63 -0
- package/dist/core/team.d.ts +34 -0
- package/dist/core/text.d.ts +8 -0
- package/dist/core/tournament.d.ts +25 -0
- package/dist/core/types.d.ts +650 -0
- package/dist/engines/command-runner.d.ts +1 -0
- package/dist/engines/conformance.d.ts +1 -0
- package/dist/engines/engine.d.ts +4 -0
- package/dist/engines/failure.d.ts +1 -0
- package/dist/engines/fallback.d.ts +35 -0
- package/dist/engines/message-map.d.ts +1 -0
- package/dist/engines/mock.d.ts +1 -0
- package/dist/engines/preflight.d.ts +36 -0
- package/dist/env/command.d.ts +50 -0
- package/dist/env/command.js +65 -0
- package/dist/env/command.js.map +1 -0
- package/dist/env/environment.d.ts +4 -0
- package/dist/env/mock.d.ts +24 -0
- package/dist/events/conformance.d.ts +1 -0
- package/dist/events/envelope.d.ts +1 -0
- package/dist/events/jsonl-store.d.ts +8 -0
- package/dist/events/store.d.ts +1 -0
- package/dist/graph/commands.d.ts +5 -0
- package/dist/graph/conformance.d.ts +32 -0
- package/dist/graph/kernel.d.ts +5 -0
- package/dist/graph/plan.d.ts +1 -0
- package/dist/graph/type.d.ts +7 -0
- package/dist/graph/value.d.ts +1 -0
- package/dist/graph-types/dag.d.ts +137 -0
- package/dist/graph-types/loop.d.ts +194 -0
- package/dist/graph-types/team.d.ts +68 -0
- package/dist/memory.d.ts +82 -0
- package/dist/memory.js +397 -0
- package/dist/memory.js.map +1 -0
- package/dist/proof/acceptance.d.ts +5 -0
- package/dist/proof/artifact.d.ts +6 -0
- package/dist/proof/cache.d.ts +4 -0
- package/dist/runtime/attempt.d.ts +19 -0
- package/dist/runtime/budget.d.ts +4 -0
- package/dist/runtime/engine-availability.d.ts +18 -0
- package/dist/runtime/graph-executor.d.ts +7 -0
- package/dist/runtime/monitor.d.ts +80 -0
- package/dist/runtime/node-lifecycle.d.ts +84 -0
- package/dist/runtime/paths.d.ts +2 -0
- package/dist/runtime/persist.d.ts +31 -0
- package/dist/runtime/preflight-record.d.ts +149 -0
- package/dist/runtime/process-tree.d.ts +1 -0
- package/dist/runtime/result-contract.d.ts +4 -0
- package/dist/runtime/result-parts.d.ts +1 -0
- package/dist/runtime/run-definition.d.ts +24 -0
- package/dist/runtime/run-event.d.ts +9 -0
- package/dist/runtime/runner.d.ts +139 -0
- package/dist/runtime/supervisor.d.ts +111 -0
- package/dist/runtime/team-rooms.d.ts +13 -0
- package/dist/runtime/workspace-policy.d.ts +25 -0
- package/dist/storage/error.d.ts +1 -0
- package/dist/storage/id.d.ts +1 -0
- package/dist/storage/local.d.ts +12 -0
- package/dist/storage/local.js +1492 -0
- package/dist/storage/local.js.map +1 -0
- package/dist/testing.d.ts +15 -0
- package/dist/testing.js +274 -0
- package/dist/testing.js.map +1 -0
- package/dist/workflow-agent-response.d.ts +3 -0
- package/dist/workflow-support.d.ts +36 -0
- package/dist/workflow-support.js +5 -0
- package/dist/workflow-support.js.map +1 -0
- package/dist/workflow.d.ts +73 -0
- package/dist/workspace/conformance.d.ts +1 -0
- package/dist/workspace/git-provider.d.ts +26 -0
- package/dist/workspace/provider.d.ts +2 -0
- package/package.json +91 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stats collector. Subscribes to the event stream and accumulates everything
|
|
3
|
+
* a host status view needs: per-loop iteration counts, review
|
|
4
|
+
* pass/fail tallies, token usage by model, errors, and wall-clock timing.
|
|
5
|
+
*/
|
|
6
|
+
import type { LoopEvent, Outcome } from './types.js';
|
|
7
|
+
export interface LoopStat {
|
|
8
|
+
path: string;
|
|
9
|
+
iterations: number;
|
|
10
|
+
reviewsPassed: number;
|
|
11
|
+
reviewsFailed: number;
|
|
12
|
+
lastStatus?: Outcome['status'];
|
|
13
|
+
}
|
|
14
|
+
export interface ModelUsage {
|
|
15
|
+
model: string;
|
|
16
|
+
calls: number;
|
|
17
|
+
reportedCalls: number;
|
|
18
|
+
unknownUsageCalls: number;
|
|
19
|
+
inputTokens: number;
|
|
20
|
+
outputTokens: number;
|
|
21
|
+
cacheCreationInputTokens?: number;
|
|
22
|
+
cacheReadInputTokens?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface ErrorEntry {
|
|
25
|
+
path: string;
|
|
26
|
+
code: string;
|
|
27
|
+
message: string;
|
|
28
|
+
ts: number;
|
|
29
|
+
}
|
|
30
|
+
export interface StatsSnapshot {
|
|
31
|
+
startedAt: number;
|
|
32
|
+
elapsedMs: number;
|
|
33
|
+
loopRuns: LoopStat[];
|
|
34
|
+
models: ModelUsage[];
|
|
35
|
+
totalInputTokens: number;
|
|
36
|
+
totalOutputTokens: number;
|
|
37
|
+
/**
|
|
38
|
+
* What the whole run created and read from cache. The per-model breakdown
|
|
39
|
+
* carried these already; the run-wide totals did not, so nothing could
|
|
40
|
+
* answer "what did this run read from cache" without summing models by hand.
|
|
41
|
+
*/
|
|
42
|
+
totalCacheCreationInputTokens: number;
|
|
43
|
+
totalCacheReadInputTokens: number;
|
|
44
|
+
/**
|
|
45
|
+
* How many calls reported no usage at all. The per-call line says "usage
|
|
46
|
+
* unknown" rather than inventing a zero; without this the aggregate quietly
|
|
47
|
+
* drops those calls and a total that might be missing three of them looks
|
|
48
|
+
* complete.
|
|
49
|
+
*/
|
|
50
|
+
totalUnmeasuredCalls: number;
|
|
51
|
+
agentCalls: number;
|
|
52
|
+
errors: ErrorEntry[];
|
|
53
|
+
}
|
|
54
|
+
export declare class Stats {
|
|
55
|
+
private readonly startedAt;
|
|
56
|
+
private readonly loopRuns;
|
|
57
|
+
private readonly models;
|
|
58
|
+
private readonly errors;
|
|
59
|
+
record(event: LoopEvent): void;
|
|
60
|
+
snapshot(): StatsSnapshot;
|
|
61
|
+
private loopFor;
|
|
62
|
+
private modelFor;
|
|
63
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CallbackGateDefinition } from '../callback/gate.js';
|
|
2
|
+
import type { EngineRef } from '../engines/engine.js';
|
|
3
|
+
import { type ReviewPanelConfig } from './feedback.js';
|
|
4
|
+
import type { Job, Outcome } from './types.js';
|
|
5
|
+
export interface TeamAgent {
|
|
6
|
+
name: string;
|
|
7
|
+
role: string;
|
|
8
|
+
brief: string;
|
|
9
|
+
engine: EngineRef;
|
|
10
|
+
}
|
|
11
|
+
export type TeamReview = {
|
|
12
|
+
kind: 'panel';
|
|
13
|
+
config: ReviewPanelConfig;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'callback';
|
|
16
|
+
definition: CallbackGateDefinition;
|
|
17
|
+
};
|
|
18
|
+
export interface TeamConfig {
|
|
19
|
+
task: string;
|
|
20
|
+
agents: readonly TeamAgent[];
|
|
21
|
+
review?: TeamReview;
|
|
22
|
+
}
|
|
23
|
+
export interface TeamAgentResult {
|
|
24
|
+
name: string;
|
|
25
|
+
role: string;
|
|
26
|
+
outcome: Outcome;
|
|
27
|
+
}
|
|
28
|
+
export interface TeamResult {
|
|
29
|
+
task: string;
|
|
30
|
+
agents: readonly TeamAgentResult[];
|
|
31
|
+
integrated: boolean;
|
|
32
|
+
review?: Outcome;
|
|
33
|
+
}
|
|
34
|
+
export declare function team(config: TeamConfig): Job;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared text helpers, so the same trim/truncate logic isn't re-implemented
|
|
3
|
+
* (subtly differently) across modules.
|
|
4
|
+
*/
|
|
5
|
+
/** Collapse all runs of whitespace to single spaces, and trim. */
|
|
6
|
+
export declare function oneLine(text: string): string;
|
|
7
|
+
/** Truncate to `max` chars, appending a `\n…` marker when it overflows. */
|
|
8
|
+
export declare function truncate(s: string, max: number): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tournament runs alternative approaches to the same task. Where a DAG fans out
|
|
3
|
+
* disjoint work and lands all of it, a tournament runs N candidates, each in its own
|
|
4
|
+
* isolated worktree, judges them, lands only the winner and discards the rest.
|
|
5
|
+
*
|
|
6
|
+
* It composes over the worktree primitives, no new machinery. Only one branch is ever
|
|
7
|
+
* merged (the winner, off an unchanged HEAD), so there is no conflict to resolve.
|
|
8
|
+
*/
|
|
9
|
+
import type { Job, JobContext, Outcome } from './types.js';
|
|
10
|
+
export interface TournamentConfig {
|
|
11
|
+
name: string;
|
|
12
|
+
/** Candidates to run. */
|
|
13
|
+
n: number;
|
|
14
|
+
/** Build the candidate job for attempt `i` (0-based): same task, varied angle. */
|
|
15
|
+
candidate: (i: number) => Job;
|
|
16
|
+
/**
|
|
17
|
+
* Score a finished candidate (higher wins). Run against the candidate's own
|
|
18
|
+
* context, so it can read the candidate's workspace. The highest-scoring
|
|
19
|
+
* passing candidate lands back; ties break to the earliest.
|
|
20
|
+
*/
|
|
21
|
+
judge: (outcome: Outcome, ctx: JobContext) => number | Promise<number>;
|
|
22
|
+
/** Max candidates running at once. Default `n`. */
|
|
23
|
+
concurrency?: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function tournament(config: TournamentConfig): Job;
|