@dogpile/sdk 0.3.0 → 0.4.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/CHANGELOG.md +145 -0
- package/README.md +1 -0
- package/dist/browser/index.js +2270 -507
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/openai-compatible.d.ts +11 -0
- package/dist/providers/openai-compatible.d.ts.map +1 -1
- package/dist/providers/openai-compatible.js +87 -2
- package/dist/providers/openai-compatible.js.map +1 -1
- package/dist/runtime/broadcast.d.ts.map +1 -1
- package/dist/runtime/broadcast.js +1 -13
- package/dist/runtime/broadcast.js.map +1 -1
- package/dist/runtime/cancellation.d.ts +26 -0
- package/dist/runtime/cancellation.d.ts.map +1 -1
- package/dist/runtime/cancellation.js +38 -1
- package/dist/runtime/cancellation.js.map +1 -1
- package/dist/runtime/coordinator.d.ts +74 -1
- package/dist/runtime/coordinator.d.ts.map +1 -1
- package/dist/runtime/coordinator.js +929 -34
- package/dist/runtime/coordinator.js.map +1 -1
- package/dist/runtime/decisions.d.ts +25 -3
- package/dist/runtime/decisions.d.ts.map +1 -1
- package/dist/runtime/decisions.js +241 -3
- package/dist/runtime/decisions.js.map +1 -1
- package/dist/runtime/defaults.d.ts +37 -1
- package/dist/runtime/defaults.d.ts.map +1 -1
- package/dist/runtime/defaults.js +347 -0
- package/dist/runtime/defaults.js.map +1 -1
- package/dist/runtime/engine.d.ts.map +1 -1
- package/dist/runtime/engine.js +254 -24
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/ids.d.ts +19 -0
- package/dist/runtime/ids.d.ts.map +1 -0
- package/dist/runtime/ids.js +36 -0
- package/dist/runtime/ids.js.map +1 -0
- package/dist/runtime/logger.d.ts +61 -0
- package/dist/runtime/logger.d.ts.map +1 -0
- package/dist/runtime/logger.js +114 -0
- package/dist/runtime/logger.js.map +1 -0
- package/dist/runtime/retry.d.ts +99 -0
- package/dist/runtime/retry.d.ts.map +1 -0
- package/dist/runtime/retry.js +181 -0
- package/dist/runtime/retry.js.map +1 -0
- package/dist/runtime/sequential.d.ts.map +1 -1
- package/dist/runtime/sequential.js +9 -11
- package/dist/runtime/sequential.js.map +1 -1
- package/dist/runtime/shared.d.ts.map +1 -1
- package/dist/runtime/shared.js +1 -13
- package/dist/runtime/shared.js.map +1 -1
- package/dist/runtime/tools/built-in.d.ts +99 -0
- package/dist/runtime/tools/built-in.d.ts.map +1 -0
- package/dist/runtime/tools/built-in.js +577 -0
- package/dist/runtime/tools/built-in.js.map +1 -0
- package/dist/runtime/tools/vercel-ai.d.ts +67 -0
- package/dist/runtime/tools/vercel-ai.d.ts.map +1 -0
- package/dist/runtime/tools/vercel-ai.js +148 -0
- package/dist/runtime/tools/vercel-ai.js.map +1 -0
- package/dist/runtime/tools.d.ts +5 -268
- package/dist/runtime/tools.d.ts.map +1 -1
- package/dist/runtime/tools.js +7 -770
- package/dist/runtime/tools.js.map +1 -1
- package/dist/runtime/validation.d.ts +10 -0
- package/dist/runtime/validation.d.ts.map +1 -1
- package/dist/runtime/validation.js +73 -0
- package/dist/runtime/validation.js.map +1 -1
- package/dist/types/benchmark.d.ts +276 -0
- package/dist/types/benchmark.d.ts.map +1 -0
- package/dist/types/benchmark.js +2 -0
- package/dist/types/benchmark.js.map +1 -0
- package/dist/types/events.d.ts +816 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +2 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/replay.d.ts +173 -0
- package/dist/types/replay.d.ts.map +1 -0
- package/dist/types/replay.js +2 -0
- package/dist/types/replay.js.map +1 -0
- package/dist/types.d.ts +135 -938
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +27 -1
- package/src/index.ts +14 -0
- package/src/providers/openai-compatible.ts +82 -3
- package/src/runtime/broadcast.ts +1 -16
- package/src/runtime/cancellation.ts +59 -1
- package/src/runtime/coordinator.ts +1164 -34
- package/src/runtime/decisions.ts +307 -4
- package/src/runtime/defaults.ts +376 -0
- package/src/runtime/engine.ts +363 -24
- package/src/runtime/ids.ts +41 -0
- package/src/runtime/logger.ts +152 -0
- package/src/runtime/retry.ts +270 -0
- package/src/runtime/sequential.ts +10 -13
- package/src/runtime/shared.ts +1 -16
- package/src/runtime/tools/built-in.ts +875 -0
- package/src/runtime/tools/vercel-ai.ts +269 -0
- package/src/runtime/tools.ts +60 -1255
- package/src/runtime/validation.ts +81 -0
- package/src/types/benchmark.ts +300 -0
- package/src/types/events.ts +895 -0
- package/src/types/replay.ts +212 -0
- package/src/types.ts +251 -997
package/src/types.ts
CHANGED
|
@@ -87,6 +87,14 @@ export type DogpileProviderInvalidRequestError = DogpileErrorBase<"provider-inva
|
|
|
87
87
|
export type DogpileProviderInvalidResponseError = DogpileErrorBase<"provider-invalid-response">;
|
|
88
88
|
export type DogpileProviderNotFoundError = DogpileErrorBase<"provider-not-found">;
|
|
89
89
|
export type DogpileProviderRateLimitedError = DogpileErrorBase<"provider-rate-limited">;
|
|
90
|
+
/**
|
|
91
|
+
* Provider timeout errors may include `detail.source?: "provider" | "engine"`.
|
|
92
|
+
*
|
|
93
|
+
* Absence is backwards-compatible and should be interpreted as `"provider"`.
|
|
94
|
+
* `"engine"` means a child engine's own deadline expired before the provider
|
|
95
|
+
* returned; parent budget propagation remains `code: "aborted"` with
|
|
96
|
+
* `detail.reason: "timeout"`.
|
|
97
|
+
*/
|
|
90
98
|
export type DogpileProviderTimeoutError = DogpileErrorBase<"provider-timeout">;
|
|
91
99
|
export type DogpileProviderUnavailableError = DogpileErrorBase<"provider-unavailable">;
|
|
92
100
|
export type DogpileProviderUnsupportedError = DogpileErrorBase<"provider-unsupported">;
|
|
@@ -792,191 +800,30 @@ export interface ModelResponse {
|
|
|
792
800
|
readonly metadata?: JsonObject;
|
|
793
801
|
}
|
|
794
802
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
* Normalized run inputs persisted inside the replay trace artifact.
|
|
819
|
-
*/
|
|
820
|
-
export interface ReplayTraceRunInputs {
|
|
821
|
-
/** Run input artifact discriminant. */
|
|
822
|
-
readonly kind: "replay-trace-run-inputs";
|
|
823
|
-
/** Mission or intent supplied by the caller. */
|
|
824
|
-
readonly intent: string;
|
|
825
|
-
/** Exact normalized protocol config used for execution. */
|
|
826
|
-
readonly protocol: ProtocolConfig;
|
|
827
|
-
/** Selected cost/quality tier. */
|
|
828
|
-
readonly tier: Tier;
|
|
829
|
-
/** Configured model provider id. */
|
|
830
|
-
readonly modelProviderId: string;
|
|
831
|
-
/** Concrete agent roster visible to the protocol. */
|
|
832
|
-
readonly agents: readonly AgentSpec[];
|
|
833
|
-
/** Temperature supplied to provider requests. */
|
|
834
|
-
readonly temperature: number;
|
|
835
|
-
}
|
|
803
|
+
// Replay trace types: see src/types/replay.ts
|
|
804
|
+
import type {
|
|
805
|
+
ReplayTraceBudget,
|
|
806
|
+
ReplayTraceBudgetStateChange,
|
|
807
|
+
ReplayTraceFinalOutput,
|
|
808
|
+
ReplayTraceProtocolDecision,
|
|
809
|
+
ReplayTraceProtocolDecisionType,
|
|
810
|
+
ReplayTraceProviderCall,
|
|
811
|
+
ReplayTraceRunInputs,
|
|
812
|
+
ReplayTraceSchemaVersion,
|
|
813
|
+
ReplayTraceSeed
|
|
814
|
+
} from "./types/replay.js";
|
|
815
|
+
export type {
|
|
816
|
+
ReplayTraceBudget,
|
|
817
|
+
ReplayTraceBudgetStateChange,
|
|
818
|
+
ReplayTraceFinalOutput,
|
|
819
|
+
ReplayTraceProtocolDecision,
|
|
820
|
+
ReplayTraceProtocolDecisionType,
|
|
821
|
+
ReplayTraceProviderCall,
|
|
822
|
+
ReplayTraceRunInputs,
|
|
823
|
+
ReplayTraceSchemaVersion,
|
|
824
|
+
ReplayTraceSeed
|
|
825
|
+
};
|
|
836
826
|
|
|
837
|
-
/**
|
|
838
|
-
* Budget and stop-policy artifact persisted inside replay traces.
|
|
839
|
-
*/
|
|
840
|
-
export interface ReplayTraceBudget {
|
|
841
|
-
/** Budget artifact discriminant. */
|
|
842
|
-
readonly kind: "replay-trace-budget";
|
|
843
|
-
/** Selected cost/quality tier. */
|
|
844
|
-
readonly tier: Tier;
|
|
845
|
-
/** Optional hard caps supplied by the caller. */
|
|
846
|
-
readonly caps?: Omit<Budget, "tier">;
|
|
847
|
-
/** Optional composable termination policy used by the protocol. */
|
|
848
|
-
readonly termination?: TerminationCondition;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
/**
|
|
852
|
-
* Budget state snapshot derived from a cost-bearing trace event.
|
|
853
|
-
*
|
|
854
|
-
* @remarks
|
|
855
|
-
* Replay consumers can inspect this artifact without walking the full event
|
|
856
|
-
* log. Entries are emitted for model-turn accounting changes, coordination
|
|
857
|
-
* barriers that expose cumulative cost, budget stops, and final completion.
|
|
858
|
-
*/
|
|
859
|
-
export interface ReplayTraceBudgetStateChange {
|
|
860
|
-
/** Budget state artifact discriminant. */
|
|
861
|
-
readonly kind: "replay-trace-budget-state-change";
|
|
862
|
-
/** Zero-based event index that exposed this budget state. */
|
|
863
|
-
readonly eventIndex: number;
|
|
864
|
-
/** Source event type for the budget state. */
|
|
865
|
-
readonly eventType: "agent-turn" | "broadcast" | "budget-stop" | "final";
|
|
866
|
-
/** ISO-8601 timestamp from the source event. */
|
|
867
|
-
readonly at: string;
|
|
868
|
-
/** Cumulative cost visible at this point in the run. */
|
|
869
|
-
readonly cost: CostSummary;
|
|
870
|
-
/** Completed model-turn iteration count when known. */
|
|
871
|
-
readonly iteration?: number;
|
|
872
|
-
/** Elapsed runtime in milliseconds when known. */
|
|
873
|
-
readonly elapsedMs?: number;
|
|
874
|
-
/** Budget stop reason when this state records a halt. */
|
|
875
|
-
readonly budgetReason?: BudgetStopReason;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
/**
|
|
879
|
-
* Provider-neutral protocol decision kinds recorded for replay.
|
|
880
|
-
*/
|
|
881
|
-
export type ReplayTraceProtocolDecisionType =
|
|
882
|
-
| "assign-role"
|
|
883
|
-
| "select-agent-turn"
|
|
884
|
-
| "start-model-call"
|
|
885
|
-
| "complete-model-call"
|
|
886
|
-
| "observe-model-output"
|
|
887
|
-
| "start-tool-call"
|
|
888
|
-
| "complete-tool-call"
|
|
889
|
-
| "collect-broadcast-round"
|
|
890
|
-
| "stop-for-budget"
|
|
891
|
-
| "finalize-output";
|
|
892
|
-
|
|
893
|
-
/**
|
|
894
|
-
* Protocol-level decision appended during execution.
|
|
895
|
-
*/
|
|
896
|
-
export interface ReplayTraceProtocolDecision {
|
|
897
|
-
/** Decision artifact discriminant. */
|
|
898
|
-
readonly kind: "replay-trace-protocol-decision";
|
|
899
|
-
/** Zero-based event index that produced this decision. */
|
|
900
|
-
readonly eventIndex: number;
|
|
901
|
-
/** Event type that records the decision. */
|
|
902
|
-
readonly eventType: RunEvent["type"];
|
|
903
|
-
/** Coordination protocol that made the decision. */
|
|
904
|
-
readonly protocol: Protocol;
|
|
905
|
-
/** Provider-neutral decision kind for replay tooling. */
|
|
906
|
-
readonly decision: ReplayTraceProtocolDecisionType;
|
|
907
|
-
/** ISO-8601 timestamp from the source event. */
|
|
908
|
-
readonly at: string;
|
|
909
|
-
/** Agent involved in the decision, when agent-scoped. */
|
|
910
|
-
readonly agentId?: string;
|
|
911
|
-
/** Role involved in the decision, when agent-scoped. */
|
|
912
|
-
readonly role?: string;
|
|
913
|
-
/** Provider call involved in the decision, when model-scoped. */
|
|
914
|
-
readonly callId?: string;
|
|
915
|
-
/** Provider involved in the decision, when model-scoped. */
|
|
916
|
-
readonly providerId?: string;
|
|
917
|
-
/** Tool call involved in the decision, when tool-scoped. */
|
|
918
|
-
readonly toolCallId?: string;
|
|
919
|
-
/** Tool identity involved in the decision, when tool-scoped. */
|
|
920
|
-
readonly tool?: RuntimeToolIdentity;
|
|
921
|
-
/** One-based protocol turn for turn-scoped decisions. */
|
|
922
|
-
readonly turn?: number;
|
|
923
|
-
/** Coordinator phase for coordinator protocol turn decisions. */
|
|
924
|
-
readonly phase?: "plan" | "worker" | "final-synthesis";
|
|
925
|
-
/** One-based broadcast round for grouped broadcast decisions. */
|
|
926
|
-
readonly round?: number;
|
|
927
|
-
/** Number of transcript entries visible after this decision. */
|
|
928
|
-
readonly transcriptEntryCount?: number;
|
|
929
|
-
/** Number of contributions collected at a broadcast barrier. */
|
|
930
|
-
readonly contributionCount?: number;
|
|
931
|
-
/** Prompt/input associated with turn decisions. */
|
|
932
|
-
readonly input?: string;
|
|
933
|
-
/** Output associated with turn or final decisions. */
|
|
934
|
-
readonly output?: string;
|
|
935
|
-
/** Cumulative cost visible at this decision point. */
|
|
936
|
-
readonly cost?: CostSummary;
|
|
937
|
-
/** Normalized budget stop reason for budget-stop decisions. */
|
|
938
|
-
readonly budgetReason?: BudgetStopReason;
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
/**
|
|
942
|
-
* Provider call metadata and response captured for replay inspection.
|
|
943
|
-
*/
|
|
944
|
-
export interface ReplayTraceProviderCall {
|
|
945
|
-
/** Provider call artifact discriminant. */
|
|
946
|
-
readonly kind: "replay-trace-provider-call";
|
|
947
|
-
/** Stable call id within the run. */
|
|
948
|
-
readonly callId: string;
|
|
949
|
-
/** Configured model provider id. */
|
|
950
|
-
readonly providerId: string;
|
|
951
|
-
/** ISO-8601 timestamp before the provider call started. */
|
|
952
|
-
readonly startedAt: string;
|
|
953
|
-
/** ISO-8601 timestamp after the provider call completed. */
|
|
954
|
-
readonly completedAt: string;
|
|
955
|
-
/** Agent that requested this provider call. */
|
|
956
|
-
readonly agentId: string;
|
|
957
|
-
/** Role that requested this provider call. */
|
|
958
|
-
readonly role: string;
|
|
959
|
-
/** Request handed to the configured model provider. */
|
|
960
|
-
readonly request: ModelRequest;
|
|
961
|
-
/** Response returned by the configured model provider. */
|
|
962
|
-
readonly response: ModelResponse;
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
/**
|
|
966
|
-
* Final output artifact persisted inside replay traces.
|
|
967
|
-
*/
|
|
968
|
-
export interface ReplayTraceFinalOutput {
|
|
969
|
-
/** Final output artifact discriminant. */
|
|
970
|
-
readonly kind: "replay-trace-final-output";
|
|
971
|
-
/** Final synthesized output returned by the run. */
|
|
972
|
-
readonly output: string;
|
|
973
|
-
/** Total cost at completion. */
|
|
974
|
-
readonly cost: CostSummary;
|
|
975
|
-
/** ISO-8601 completion timestamp from the terminal event. */
|
|
976
|
-
readonly completedAt: string;
|
|
977
|
-
/** Link to the completed transcript artifact. */
|
|
978
|
-
readonly transcript: TranscriptLink;
|
|
979
|
-
}
|
|
980
827
|
|
|
981
828
|
/**
|
|
982
829
|
* Incremental text produced by a streaming model provider.
|
|
@@ -1048,6 +895,14 @@ export interface ConfiguredModelProvider {
|
|
|
1048
895
|
* support incremental output and for callers that prefer batch execution.
|
|
1049
896
|
*/
|
|
1050
897
|
stream?(request: ModelRequest): AsyncIterable<ModelOutputChunk>;
|
|
898
|
+
/**
|
|
899
|
+
* Optional provider hints for the runtime. Absent or omitted is treated as
|
|
900
|
+
* `remote` for concurrency clamping (CONCURRENCY-02 / Phase 3 D-01).
|
|
901
|
+
*/
|
|
902
|
+
readonly metadata?: {
|
|
903
|
+
/** Locality hint for dispatch clamping. Absent -> "remote" for clamping. */
|
|
904
|
+
readonly locality?: "local" | "remote";
|
|
905
|
+
};
|
|
1051
906
|
}
|
|
1052
907
|
|
|
1053
908
|
/**
|
|
@@ -1411,817 +1266,108 @@ export interface RuntimeToolAdapterContract<Input extends object = JsonObject, O
|
|
|
1411
1266
|
validateInput(input: Readonly<Input>): RuntimeToolValidationResult;
|
|
1412
1267
|
}
|
|
1413
1268
|
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
* @remarks
|
|
1516
|
-
* Use this derived shape after selecting the protocol under test. It preserves
|
|
1517
|
-
* the shared benchmark controls from {@link BenchmarkRunnerConfig} and adds a
|
|
1518
|
-
* named or explicit {@link ProtocolConfig}, which lets reproduction code tune
|
|
1519
|
-
* protocol-native parameters without widening the high-level API.
|
|
1520
|
-
*/
|
|
1521
|
-
export interface ProtocolBenchmarkRunConfig extends BenchmarkRunnerConfig {
|
|
1522
|
-
/** Protocol being evaluated under the shared benchmark settings. */
|
|
1523
|
-
readonly protocol: Protocol | ProtocolConfig;
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
|
-
/**
|
|
1527
|
-
* Serializable benchmark protocol descriptor persisted with run artifacts.
|
|
1528
|
-
*
|
|
1529
|
-
* @remarks
|
|
1530
|
-
* Benchmark artifacts record both the normalized protocol name and the exact
|
|
1531
|
-
* caller-supplied protocol config so a reproduction harness can distinguish
|
|
1532
|
-
* `"sequential"` defaults from `{ kind: "sequential", maxTurns: 4 }`.
|
|
1533
|
-
*/
|
|
1534
|
-
export interface BenchmarkProtocolArtifact {
|
|
1535
|
-
/** Normalized protocol name used for comparison grouping. */
|
|
1536
|
-
readonly kind: Protocol;
|
|
1537
|
-
/** Exact protocol value supplied to the runner. */
|
|
1538
|
-
readonly config: Protocol | ProtocolConfig;
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
/**
|
|
1542
|
-
* Reproducibility metadata persisted with every benchmark run artifact.
|
|
1543
|
-
*
|
|
1544
|
-
* @remarks
|
|
1545
|
-
* This shape intentionally stores provider identity and serializable model
|
|
1546
|
-
* settings, but not the provider implementation itself. Callers own provider
|
|
1547
|
-
* construction and external storage; Dogpile owns the portable artifact shape.
|
|
1548
|
-
*/
|
|
1549
|
-
export interface BenchmarkReproducibilityArtifact {
|
|
1550
|
-
/** Benchmark task input used for this run. */
|
|
1551
|
-
readonly task: BenchmarkTaskInput;
|
|
1552
|
-
/** Shared budget and cap policy used for this run. */
|
|
1553
|
-
readonly budget: BenchmarkBudget;
|
|
1554
|
-
/** Protocol selected for this run. */
|
|
1555
|
-
readonly protocol: BenchmarkProtocolArtifact;
|
|
1556
|
-
/** Provider id recorded from the configured model. */
|
|
1557
|
-
readonly modelProviderId: string;
|
|
1558
|
-
/** Optional fixed temperature used for the run. */
|
|
1559
|
-
readonly temperature?: number;
|
|
1560
|
-
/** Optional deterministic seed recorded for provider adapters that support it. */
|
|
1561
|
-
readonly seed?: number;
|
|
1562
|
-
/** Additional serializable provider or run metadata. */
|
|
1563
|
-
readonly modelMetadata?: JsonObject;
|
|
1564
|
-
/** Concrete agent roster used for the run. */
|
|
1565
|
-
readonly agents: readonly AgentSpec[];
|
|
1566
|
-
/** Additional serializable benchmark metadata. */
|
|
1567
|
-
readonly benchmarkMetadata?: JsonObject;
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
/**
|
|
1571
|
-
* Cost and budget metadata recorded for one benchmark run.
|
|
1572
|
-
*
|
|
1573
|
-
* @remarks
|
|
1574
|
-
* This accounting block is intentionally duplicated from the run result and
|
|
1575
|
-
* benchmark controls so benchmark reports can group, filter, and audit spend
|
|
1576
|
-
* without unpacking the full trace or reproduction object. Utilization fields
|
|
1577
|
-
* are only present when the corresponding cap was configured.
|
|
1578
|
-
*/
|
|
1579
|
-
export interface BenchmarkCostAccounting {
|
|
1580
|
-
/** Accounting artifact discriminant for future benchmark metadata unions. */
|
|
1581
|
-
readonly kind: "benchmark-cost-accounting";
|
|
1582
|
-
/** Named budget/cost tier selected for this benchmark run. */
|
|
1583
|
-
readonly tier: Tier;
|
|
1584
|
-
/** Shared benchmark budget and cap policy used for this run. */
|
|
1585
|
-
readonly budget: BenchmarkBudget;
|
|
1586
|
-
/** Total token and spend accounting observed for this run. */
|
|
1587
|
-
readonly cost: CostSummary;
|
|
1588
|
-
/** Fraction of the configured USD cap consumed, when `maxUsd` is present. */
|
|
1589
|
-
readonly usdCapUtilization?: number;
|
|
1590
|
-
/** Fraction of the configured total-token cap consumed, when `maxTotalTokens` is present. */
|
|
1591
|
-
readonly totalTokenCapUtilization?: number;
|
|
1592
|
-
}
|
|
1593
|
-
|
|
1594
|
-
/**
|
|
1595
|
-
* Structured streaming event log captured for one benchmark run.
|
|
1596
|
-
*
|
|
1597
|
-
* @remarks
|
|
1598
|
-
* Benchmark artifacts keep this log beside the full trace so reproduction
|
|
1599
|
-
* harnesses can inspect exactly what the streaming API yielded during the run
|
|
1600
|
-
* without unpacking unrelated trace metadata. The `events` array must match
|
|
1601
|
-
* `trace.events` for completed runs.
|
|
1602
|
-
*/
|
|
1603
|
-
export interface BenchmarkStreamingEventLog {
|
|
1604
|
-
/** Event-log discriminant for future benchmark observability artifacts. */
|
|
1605
|
-
readonly kind: "benchmark-streaming-event-log";
|
|
1606
|
-
/** Stable run id shared by the benchmark artifact and trace. */
|
|
1607
|
-
readonly runId: string;
|
|
1608
|
-
/** Protocol whose streaming events were captured. */
|
|
1609
|
-
readonly protocol: Protocol;
|
|
1610
|
-
/** Ordered event kinds for compact coverage checks. */
|
|
1611
|
-
readonly eventTypes: readonly RunEvent["type"][];
|
|
1612
|
-
/** Number of streaming events captured. */
|
|
1613
|
-
readonly eventCount: number;
|
|
1614
|
-
/** Complete ordered streaming events yielded by the run. */
|
|
1615
|
-
readonly events: readonly RunEvent[];
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
/**
|
|
1619
|
-
* Serializable score persisted for one protocol benchmark artifact.
|
|
1620
|
-
*
|
|
1621
|
-
* @remarks
|
|
1622
|
-
* The score is protocol-scoped because paper reproduction reports compare the
|
|
1623
|
-
* same task across protocol variants. When a judge supplies
|
|
1624
|
-
* {@link RunResult.quality}, the benchmark score records that value on a
|
|
1625
|
-
* 0..100 scale. Otherwise Dogpile computes a conservative artifact-completeness
|
|
1626
|
-
* score from the captured output, transcript, streaming event log, and budget
|
|
1627
|
-
* accounting so unjudged benchmark artifacts still carry an auditable score
|
|
1628
|
-
* derived from stored data.
|
|
1629
|
-
*/
|
|
1630
|
-
export interface BenchmarkProtocolScore {
|
|
1631
|
-
/** Score artifact discriminant for future benchmark scoring variants. */
|
|
1632
|
-
readonly kind: "benchmark-protocol-score";
|
|
1633
|
-
/** Protocol this score belongs to. */
|
|
1634
|
-
readonly protocol: Protocol;
|
|
1635
|
-
/** Score in the inclusive range `0..100`. */
|
|
1636
|
-
readonly score: number;
|
|
1637
|
-
/** Normalized score in the inclusive range `0..1`. */
|
|
1638
|
-
readonly normalizedScore: number;
|
|
1639
|
-
/** Maximum score for the current scoring scale. */
|
|
1640
|
-
readonly maxScore: 100;
|
|
1641
|
-
/** How the score was derived. */
|
|
1642
|
-
readonly source: "run-quality" | "artifact-completeness";
|
|
1643
|
-
/** Compact scoring dimensions used to compute the stored score. */
|
|
1644
|
-
readonly dimensions: readonly BenchmarkScoreDimension[];
|
|
1645
|
-
}
|
|
1646
|
-
|
|
1647
|
-
/**
|
|
1648
|
-
* One serializable dimension contributing to a benchmark protocol score.
|
|
1649
|
-
*/
|
|
1650
|
-
export interface BenchmarkScoreDimension {
|
|
1651
|
-
/** Stable dimension name for reports. */
|
|
1652
|
-
readonly name: string;
|
|
1653
|
-
/** Earned points for this dimension. */
|
|
1654
|
-
readonly score: number;
|
|
1655
|
-
/** Maximum points available for this dimension. */
|
|
1656
|
-
readonly maxScore: number;
|
|
1657
|
-
}
|
|
1658
|
-
|
|
1659
|
-
/**
|
|
1660
|
-
* Reproducible benchmark output artifact for one protocol run.
|
|
1661
|
-
*
|
|
1662
|
-
* @remarks
|
|
1663
|
-
* This is the storage-free persistence contract for reproduction workflows:
|
|
1664
|
-
* callers can write the object to JSON, NDJSON, object storage, or a database
|
|
1665
|
-
* without Dogpile depending on Node-only filesystem APIs. It contains the final
|
|
1666
|
-
* output, full transcript, a structured streaming event log, full trace, cost
|
|
1667
|
-
* summary, and all serializable controls needed to replay the run in
|
|
1668
|
-
* caller-managed infrastructure.
|
|
1669
|
-
*/
|
|
1670
|
-
export interface BenchmarkRunArtifact {
|
|
1671
|
-
/** Artifact discriminant for future benchmark artifact unions. */
|
|
1672
|
-
readonly kind: "benchmark-run";
|
|
1673
|
-
/** Schema version for reproducible artifact consumers. */
|
|
1674
|
-
readonly schemaVersion: "1.0";
|
|
1675
|
-
/** Stable run id from the trace. */
|
|
1676
|
-
readonly runId: string;
|
|
1677
|
-
/** ISO-8601 timestamp derived from the first trace event when available. */
|
|
1678
|
-
readonly startedAt: string;
|
|
1679
|
-
/** ISO-8601 timestamp derived from the final trace event when available. */
|
|
1680
|
-
readonly completedAt: string;
|
|
1681
|
-
/** Reproduction controls and serializable fixture inputs. */
|
|
1682
|
-
readonly reproducibility: BenchmarkReproducibilityArtifact;
|
|
1683
|
-
/** Final output produced by the protocol. */
|
|
1684
|
-
readonly output: string;
|
|
1685
|
-
/** Complete normalized transcript for this run. */
|
|
1686
|
-
readonly transcript: readonly TranscriptEntry[];
|
|
1687
|
-
/** Structured streaming event log captured for this benchmark run. */
|
|
1688
|
-
readonly eventLog: BenchmarkStreamingEventLog;
|
|
1689
|
-
/** Full serializable event log and trace for this run. */
|
|
1690
|
-
readonly trace: Trace;
|
|
1691
|
-
/** Cost, tier, and benchmark budget metadata for this run. */
|
|
1692
|
-
readonly accounting: BenchmarkCostAccounting;
|
|
1693
|
-
/** Per-protocol benchmark score computed from the captured artifact data. */
|
|
1694
|
-
readonly score: BenchmarkProtocolScore;
|
|
1695
|
-
/** Total token and spend accounting for this run. */
|
|
1696
|
-
readonly cost: CostSummary;
|
|
1697
|
-
/** Optional normalized quality score in the inclusive range `0..1`. */
|
|
1698
|
-
readonly quality?: number;
|
|
1699
|
-
}
|
|
1700
|
-
|
|
1701
|
-
/**
|
|
1702
|
-
* Event emitted when a protocol assigns or records an agent role.
|
|
1703
|
-
*
|
|
1704
|
-
* @remarks
|
|
1705
|
-
* This event normally appears near the beginning of a run and establishes the
|
|
1706
|
-
* `agentId`/`role` pair that later turn and transcript records refer to. A
|
|
1707
|
-
* renderer can use it to build the participant roster before model output
|
|
1708
|
-
* starts streaming.
|
|
1709
|
-
*
|
|
1710
|
-
* Payload shape:
|
|
1711
|
-
*
|
|
1712
|
-
* - `type`: always `role-assignment`.
|
|
1713
|
-
* - `runId`: stable id shared by every event and trace object for the run.
|
|
1714
|
-
* - `at`: ISO-8601 timestamp for when the assignment was emitted.
|
|
1715
|
-
* - `agentId`: stable agent id used in events, trace, and transcript entries.
|
|
1716
|
-
* - `role`: model-visible role or perspective assigned to that agent.
|
|
1717
|
-
*/
|
|
1718
|
-
export interface RoleAssignmentEvent {
|
|
1719
|
-
/** Discriminant for event rendering and exhaustive switches. */
|
|
1720
|
-
readonly type: "role-assignment";
|
|
1721
|
-
/** Stable run id shared by all events in one workflow. */
|
|
1722
|
-
readonly runId: string;
|
|
1723
|
-
/** ISO-8601 event timestamp. */
|
|
1724
|
-
readonly at: string;
|
|
1725
|
-
/** Agent receiving the role assignment. */
|
|
1726
|
-
readonly agentId: string;
|
|
1727
|
-
/** Role assigned to the agent. */
|
|
1728
|
-
readonly role: string;
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
/**
|
|
1732
|
-
* Event emitted when Dogpile is about to ask the configured model provider for
|
|
1733
|
-
* one protocol-managed response.
|
|
1734
|
-
*
|
|
1735
|
-
* @remarks
|
|
1736
|
-
* This event is the request-side model activity counterpart to
|
|
1737
|
-
* {@link ModelResponseEvent}. Protocol implementations may omit it when they
|
|
1738
|
-
* only expose completed turns, but adapters and researcher harnesses can emit
|
|
1739
|
-
* it to make provider calls visible in the same streaming event log as agent
|
|
1740
|
-
* turns and final output.
|
|
1741
|
-
*/
|
|
1742
|
-
export interface ModelRequestEvent {
|
|
1743
|
-
/** Discriminant for event rendering and exhaustive switches. */
|
|
1744
|
-
readonly type: "model-request";
|
|
1745
|
-
/** Stable run id shared by all events in one workflow. */
|
|
1746
|
-
readonly runId: string;
|
|
1747
|
-
/** ISO-8601 event timestamp. */
|
|
1748
|
-
readonly at: string;
|
|
1749
|
-
/** Stable provider call id within the run. */
|
|
1750
|
-
readonly callId: string;
|
|
1751
|
-
/** Configured model provider id receiving the request. */
|
|
1752
|
-
readonly providerId: string;
|
|
1753
|
-
/** Agent requesting the model call. */
|
|
1754
|
-
readonly agentId: string;
|
|
1755
|
-
/** Agent role for the active model call. */
|
|
1756
|
-
readonly role: string;
|
|
1757
|
-
/** Provider-neutral request handed to the model adapter. */
|
|
1758
|
-
readonly request: ModelRequest;
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
/**
|
|
1762
|
-
* Event emitted after the configured model provider returns one response.
|
|
1763
|
-
*
|
|
1764
|
-
* @remarks
|
|
1765
|
-
* This event records provider-level model activity without forcing callers to
|
|
1766
|
-
* infer it from the higher-level {@link TurnEvent}. The response is the same
|
|
1767
|
-
* provider-neutral shape captured in replay traces, so it remains portable and
|
|
1768
|
-
* JSON-serializable across Node LTS, Bun, and browser ESM runtimes.
|
|
1769
|
-
*/
|
|
1770
|
-
export interface ModelResponseEvent {
|
|
1771
|
-
/** Discriminant for event rendering and exhaustive switches. */
|
|
1772
|
-
readonly type: "model-response";
|
|
1773
|
-
/** Stable run id shared by all events in one workflow. */
|
|
1774
|
-
readonly runId: string;
|
|
1775
|
-
/** ISO-8601 event timestamp. */
|
|
1776
|
-
readonly at: string;
|
|
1777
|
-
/** Stable provider call id within the run. */
|
|
1778
|
-
readonly callId: string;
|
|
1779
|
-
/** Configured model provider id that produced the response. */
|
|
1780
|
-
readonly providerId: string;
|
|
1781
|
-
/** Agent that requested the model call. */
|
|
1782
|
-
readonly agentId: string;
|
|
1783
|
-
/** Agent role for the completed model call. */
|
|
1784
|
-
readonly role: string;
|
|
1785
|
-
/** Provider-neutral response returned by the model adapter. */
|
|
1786
|
-
readonly response: ModelResponse;
|
|
1787
|
-
}
|
|
1788
|
-
|
|
1789
|
-
/**
|
|
1790
|
-
* Event emitted while a model turn is still generating text.
|
|
1791
|
-
*
|
|
1792
|
-
* @remarks
|
|
1793
|
-
* `model-output-chunk` lets streaming callers render provider output before
|
|
1794
|
-
* the protocol has enough information to commit the completed `agent-turn`
|
|
1795
|
-
* transcript entry. It is emitted only when the configured model provider
|
|
1796
|
-
* implements {@link ConfiguredModelProvider.stream}; non-streaming providers
|
|
1797
|
-
* continue to produce the existing role/turn/final event sequence.
|
|
1798
|
-
*
|
|
1799
|
-
* Payload shape:
|
|
1800
|
-
*
|
|
1801
|
-
* - `type`: always `model-output-chunk`.
|
|
1802
|
-
* - `runId`: stable id shared by every event and trace object for the run.
|
|
1803
|
-
* - `at`: ISO-8601 timestamp for when the chunk was observed.
|
|
1804
|
-
* - `agentId` and `role`: identify the active generating agent.
|
|
1805
|
-
* - `input`: prompt text visible to that agent for this turn.
|
|
1806
|
-
* - `chunkIndex`: zero-based chunk index within this model turn.
|
|
1807
|
-
* - `text`: text delta from the provider.
|
|
1808
|
-
* - `output`: accumulated output for this turn after applying the chunk.
|
|
1809
|
-
*/
|
|
1810
|
-
export interface ModelOutputChunkEvent {
|
|
1811
|
-
/** Discriminant for event rendering and exhaustive switches. */
|
|
1812
|
-
readonly type: "model-output-chunk";
|
|
1813
|
-
/** Stable run id shared by all events in one workflow. */
|
|
1814
|
-
readonly runId: string;
|
|
1815
|
-
/** ISO-8601 event timestamp. */
|
|
1816
|
-
readonly at: string;
|
|
1817
|
-
/** Agent currently producing output. */
|
|
1818
|
-
readonly agentId: string;
|
|
1819
|
-
/** Agent role for the active turn. */
|
|
1820
|
-
readonly role: string;
|
|
1821
|
-
/** Prompt/input visible to the agent for this turn. */
|
|
1822
|
-
readonly input: string;
|
|
1823
|
-
/** Zero-based chunk index within the active model turn. */
|
|
1824
|
-
readonly chunkIndex: number;
|
|
1825
|
-
/** Text delta produced by the model provider. */
|
|
1826
|
-
readonly text: string;
|
|
1827
|
-
/** Accumulated output for this turn after applying this chunk. */
|
|
1828
|
-
readonly output: string;
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
/**
|
|
1832
|
-
* Event emitted when a runtime tool is invoked by protocol or model policy.
|
|
1833
|
-
*
|
|
1834
|
-
* @remarks
|
|
1835
|
-
* Tools are caller-owned escape hatches. This request-side event keeps tool
|
|
1836
|
-
* invocation observable without making Dogpile core depend on Node-only
|
|
1837
|
-
* capabilities, a storage layer, or a provider-specific function-call shape.
|
|
1838
|
-
*/
|
|
1839
|
-
export interface ToolCallEvent {
|
|
1840
|
-
/** Discriminant for event rendering and exhaustive switches. */
|
|
1841
|
-
readonly type: "tool-call";
|
|
1842
|
-
/** Stable run id shared by all events in one workflow. */
|
|
1843
|
-
readonly runId: string;
|
|
1844
|
-
/** ISO-8601 event timestamp. */
|
|
1845
|
-
readonly at: string;
|
|
1846
|
-
/** Stable tool call id within the run. */
|
|
1847
|
-
readonly toolCallId: string;
|
|
1848
|
-
/** Tool identity selected for execution. */
|
|
1849
|
-
readonly tool: RuntimeToolIdentity;
|
|
1850
|
-
/** JSON-serializable tool input. */
|
|
1851
|
-
readonly input: JsonObject;
|
|
1852
|
-
/** Agent that requested the tool, when agent-scoped. */
|
|
1853
|
-
readonly agentId?: string;
|
|
1854
|
-
/** Agent role that requested the tool, when available. */
|
|
1855
|
-
readonly role?: string;
|
|
1856
|
-
}
|
|
1857
|
-
|
|
1858
|
-
/**
|
|
1859
|
-
* Event emitted after a runtime tool returns a normalized result.
|
|
1860
|
-
*
|
|
1861
|
-
* @remarks
|
|
1862
|
-
* Tool failures are data at the public boundary. The result payload uses the
|
|
1863
|
-
* same discriminated union as runtime tool adapters, allowing log consumers to
|
|
1864
|
-
* render successful outputs and normalized errors exhaustively.
|
|
1865
|
-
*/
|
|
1866
|
-
export interface ToolResultEvent {
|
|
1867
|
-
/** Discriminant for event rendering and exhaustive switches. */
|
|
1868
|
-
readonly type: "tool-result";
|
|
1869
|
-
/** Stable run id shared by all events in one workflow. */
|
|
1870
|
-
readonly runId: string;
|
|
1871
|
-
/** ISO-8601 event timestamp. */
|
|
1872
|
-
readonly at: string;
|
|
1873
|
-
/** Stable tool call id within the run. */
|
|
1874
|
-
readonly toolCallId: string;
|
|
1875
|
-
/** Tool identity that produced the result. */
|
|
1876
|
-
readonly tool: RuntimeToolIdentity;
|
|
1877
|
-
/** Normalized JSON-serializable tool result. */
|
|
1878
|
-
readonly result: RuntimeToolResult;
|
|
1879
|
-
/** Agent that requested the tool, when agent-scoped. */
|
|
1880
|
-
readonly agentId?: string;
|
|
1881
|
-
/** Agent role that requested the tool, when available. */
|
|
1882
|
-
readonly role?: string;
|
|
1883
|
-
}
|
|
1884
|
-
|
|
1885
|
-
/**
|
|
1886
|
-
* Provider-normalized participation decision parsed from paper-style agent output.
|
|
1887
|
-
*
|
|
1888
|
-
* @remarks
|
|
1889
|
-
* Dogpile preserves the raw model text on transcript entries and events. When
|
|
1890
|
-
* a model emits the labeled fields `role_selected`, `participation`,
|
|
1891
|
-
* `rationale`, and `contribution`, protocols also attach this structured
|
|
1892
|
-
* metadata so reproduction harnesses can distinguish contribution from
|
|
1893
|
-
* voluntary abstention without reparsing raw text.
|
|
1894
|
-
*/
|
|
1895
|
-
export interface AgentDecision {
|
|
1896
|
-
/** Task-specific role selected by the agent for this turn. */
|
|
1897
|
-
readonly selectedRole: string;
|
|
1898
|
-
/** Whether the agent contributed or voluntarily abstained. */
|
|
1899
|
-
readonly participation: AgentParticipation;
|
|
1900
|
-
/** Agent-provided rationale for the selected role and participation choice. */
|
|
1901
|
-
readonly rationale: string;
|
|
1902
|
-
/** Agent-provided contribution text, or abstention explanation. */
|
|
1903
|
-
readonly contribution: string;
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
|
-
/**
|
|
1907
|
-
* Agent participation state for a paper-style turn decision.
|
|
1908
|
-
*/
|
|
1909
|
-
export type AgentParticipation = "contribute" | "abstain";
|
|
1910
|
-
|
|
1911
|
-
/**
|
|
1912
|
-
* Event emitted after one agent contributes a model turn.
|
|
1913
|
-
*
|
|
1914
|
-
* @remarks
|
|
1915
|
-
* `agent-turn` is the primary streaming payload for sequential, coordinator,
|
|
1916
|
-
* shared-state, and broadcast executions. It captures the exact prompt/input
|
|
1917
|
-
* Dogpile supplied to the agent, the text returned by the model provider, and
|
|
1918
|
-
* the cumulative cost after applying that response.
|
|
1919
|
-
*
|
|
1920
|
-
* The corresponding durable transcript record contains the same
|
|
1921
|
-
* `agentId`/`role`/`input`/`output` contribution without event timing or cost
|
|
1922
|
-
* fields. Use this event for live progress UIs and the transcript for replay
|
|
1923
|
-
* or downstream application logic.
|
|
1924
|
-
*
|
|
1925
|
-
* Payload shape:
|
|
1926
|
-
*
|
|
1927
|
-
* - `type`: always `agent-turn`.
|
|
1928
|
-
* - `runId`: stable id shared by every event and trace object for the run.
|
|
1929
|
-
* - `at`: ISO-8601 timestamp for when the turn completed.
|
|
1930
|
-
* - `agentId` and `role`: identify the contributing agent.
|
|
1931
|
-
* - `input`: prompt text visible to that agent for this turn.
|
|
1932
|
-
* - `output`: generated model text produced by the agent.
|
|
1933
|
-
* - `cost`: cumulative token and spend accounting after this turn.
|
|
1934
|
-
*/
|
|
1935
|
-
export interface TurnEvent {
|
|
1936
|
-
/** Discriminant for event rendering and exhaustive switches. */
|
|
1937
|
-
readonly type: "agent-turn";
|
|
1938
|
-
/** Stable run id shared by all events in one workflow. */
|
|
1939
|
-
readonly runId: string;
|
|
1940
|
-
/** ISO-8601 event timestamp. */
|
|
1941
|
-
readonly at: string;
|
|
1942
|
-
/** Agent that produced this turn. */
|
|
1943
|
-
readonly agentId: string;
|
|
1944
|
-
/** Agent role for this turn. */
|
|
1945
|
-
readonly role: string;
|
|
1946
|
-
/** Prompt/input visible to the agent for this turn. */
|
|
1947
|
-
readonly input: string;
|
|
1948
|
-
/** Model output produced by the agent. */
|
|
1949
|
-
readonly output: string;
|
|
1950
|
-
/** Optional structured role/participation decision parsed from model output. */
|
|
1951
|
-
readonly decision?: AgentDecision;
|
|
1952
|
-
/** Cumulative cost after this turn. */
|
|
1953
|
-
readonly cost: CostSummary;
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
/**
|
|
1957
|
-
* One independent contribution captured by a broadcast round event.
|
|
1958
|
-
*
|
|
1959
|
-
* @remarks
|
|
1960
|
-
* Broadcast protocols collect one contribution per participating agent before
|
|
1961
|
-
* synthesis. The contribution payload is intentionally smaller than
|
|
1962
|
-
* {@link TurnEvent}: it is a round-level summary of model outputs, while the
|
|
1963
|
-
* complete prompt/output pair for each agent is still available as individual
|
|
1964
|
-
* `agent-turn` events and {@link TranscriptEntry} records.
|
|
1965
|
-
*
|
|
1966
|
-
* Payload shape:
|
|
1967
|
-
*
|
|
1968
|
-
* - `agentId`: stable id of the contributing agent.
|
|
1969
|
-
* - `role`: model-visible role or perspective used for that contribution.
|
|
1970
|
-
* - `output`: generated text contributed independently for the round.
|
|
1971
|
-
*/
|
|
1972
|
-
export interface BroadcastContribution {
|
|
1973
|
-
/** Agent that produced the broadcast contribution. */
|
|
1974
|
-
readonly agentId: string;
|
|
1975
|
-
/** Agent role for the contribution. */
|
|
1976
|
-
readonly role: string;
|
|
1977
|
-
/** Independent model output produced for the shared mission. */
|
|
1978
|
-
readonly output: string;
|
|
1979
|
-
/** Optional structured role/participation decision parsed from model output. */
|
|
1980
|
-
readonly decision?: AgentDecision;
|
|
1981
|
-
}
|
|
1982
|
-
|
|
1983
|
-
/**
|
|
1984
|
-
* Event emitted after agents broadcast independent contributions for a round.
|
|
1985
|
-
*
|
|
1986
|
-
* @remarks
|
|
1987
|
-
* A `broadcast` event marks the coordination moment where independently
|
|
1988
|
-
* generated agent outputs are gathered for a shared round. It does not replace
|
|
1989
|
-
* per-agent `agent-turn` events; instead, it groups their outputs by round so
|
|
1990
|
-
* observers can render the broadcast barrier and replay the paper protocol's
|
|
1991
|
-
* independent-contribution step.
|
|
1992
|
-
*
|
|
1993
|
-
* Payload shape:
|
|
1994
|
-
*
|
|
1995
|
-
* - `type`: always `broadcast`.
|
|
1996
|
-
* - `runId`: stable id shared by every event and trace object for the run.
|
|
1997
|
-
* - `at`: ISO-8601 timestamp for when the round finished.
|
|
1998
|
-
* - `round`: one-based broadcast round number.
|
|
1999
|
-
* - `contributions`: independent outputs collected for this round.
|
|
2000
|
-
* - `cost`: cumulative token and spend accounting after the round.
|
|
2001
|
-
*/
|
|
2002
|
-
export interface BroadcastEvent {
|
|
2003
|
-
/** Discriminant for event rendering and exhaustive switches. */
|
|
2004
|
-
readonly type: "broadcast";
|
|
2005
|
-
/** Stable run id shared by all events in one workflow. */
|
|
2006
|
-
readonly runId: string;
|
|
2007
|
-
/** ISO-8601 event timestamp. */
|
|
2008
|
-
readonly at: string;
|
|
2009
|
-
/** One-based broadcast round number. */
|
|
2010
|
-
readonly round: number;
|
|
2011
|
-
/** Independent contributions collected in this broadcast round. */
|
|
2012
|
-
readonly contributions: readonly BroadcastContribution[];
|
|
2013
|
-
/** Cumulative cost after this broadcast round. */
|
|
2014
|
-
readonly cost: CostSummary;
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
|
-
/**
|
|
2018
|
-
* Event emitted when a workflow halts because a configured budget cap fired.
|
|
2019
|
-
*
|
|
2020
|
-
* @remarks
|
|
2021
|
-
* `budget-stop` records the normalized cap class that stopped execution before
|
|
2022
|
-
* the final event closes the run. The detail object is JSON-serializable so
|
|
2023
|
-
* callers can persist or replay the exact cap, observed value, and limit.
|
|
2024
|
-
*/
|
|
2025
|
-
export interface BudgetStopEvent {
|
|
2026
|
-
/** Discriminant for event rendering and exhaustive switches. */
|
|
2027
|
-
readonly type: "budget-stop";
|
|
2028
|
-
/** Stable run id shared by all events in one workflow. */
|
|
2029
|
-
readonly runId: string;
|
|
2030
|
-
/** ISO-8601 event timestamp. */
|
|
2031
|
-
readonly at: string;
|
|
2032
|
-
/** Normalized machine-readable budget stop reason. */
|
|
2033
|
-
readonly reason: BudgetStopReason;
|
|
2034
|
-
/** Total cost at the stop point. */
|
|
2035
|
-
readonly cost: CostSummary;
|
|
2036
|
-
/** Completed model-turn iterations at the stop point. */
|
|
2037
|
-
readonly iteration: number;
|
|
2038
|
-
/** Elapsed runtime in milliseconds at the stop point. */
|
|
2039
|
-
readonly elapsedMs: number;
|
|
2040
|
-
/** Serializable cap diagnostics. */
|
|
2041
|
-
readonly detail: JsonObject;
|
|
2042
|
-
}
|
|
2043
|
-
|
|
2044
|
-
/**
|
|
2045
|
-
* Link from a terminal event to the completed trace transcript.
|
|
2046
|
-
*
|
|
2047
|
-
* @remarks
|
|
2048
|
-
* Final events are emitted before callers await {@link StreamHandle.result},
|
|
2049
|
-
* so this compact link tells streaming UIs exactly which transcript artifact
|
|
2050
|
-
* the terminal output closes over without duplicating every transcript entry
|
|
2051
|
-
* inside the event log.
|
|
2052
|
-
*/
|
|
2053
|
-
export interface TranscriptLink {
|
|
2054
|
-
/** Discriminant for future transcript link variants. */
|
|
2055
|
-
readonly kind: "trace-transcript";
|
|
2056
|
-
/** Number of transcript entries included in the completed trace. */
|
|
2057
|
-
readonly entryCount: number;
|
|
2058
|
-
/** Zero-based index of the last transcript entry, or `null` for empty runs. */
|
|
2059
|
-
readonly lastEntryIndex: number | null;
|
|
2060
|
-
}
|
|
2061
|
-
|
|
2062
|
-
/**
|
|
2063
|
-
* Event emitted when a workflow produces its final output.
|
|
2064
|
-
*
|
|
2065
|
-
* @remarks
|
|
2066
|
-
* `final` is the terminal streaming event for a successful run. Its `output`
|
|
2067
|
-
* value matches {@link RunResult.output}, and its `cost` value matches the
|
|
2068
|
-
* final aggregate cost returned on the result. Its `transcript` link points to
|
|
2069
|
-
* the completed {@link Trace.transcript} entries that produced the terminal
|
|
2070
|
-
* output.
|
|
2071
|
-
*
|
|
2072
|
-
* Payload shape:
|
|
2073
|
-
*
|
|
2074
|
-
* - `type`: always `final`.
|
|
2075
|
-
* - `runId`: stable id shared by every event and trace object for the run.
|
|
2076
|
-
* - `at`: ISO-8601 timestamp for when final synthesis completed.
|
|
2077
|
-
* - `output`: final synthesized answer returned to the caller.
|
|
2078
|
-
* - `cost`: total token and spend accounting for the run.
|
|
2079
|
-
* - `transcript`: compact link to the completed trace transcript.
|
|
2080
|
-
*/
|
|
2081
|
-
export interface FinalEvent {
|
|
2082
|
-
/** Discriminant for event rendering and exhaustive switches. */
|
|
2083
|
-
readonly type: "final";
|
|
2084
|
-
/** Stable run id shared by all events in one workflow. */
|
|
2085
|
-
readonly runId: string;
|
|
2086
|
-
/** ISO-8601 event timestamp. */
|
|
2087
|
-
readonly at: string;
|
|
2088
|
-
/** Final synthesized answer returned as `RunResult.output`. */
|
|
2089
|
-
readonly output: string;
|
|
2090
|
-
/** Total cost at completion. */
|
|
2091
|
-
readonly cost: CostSummary;
|
|
2092
|
-
/** Link to the completed trace transcript. */
|
|
2093
|
-
readonly transcript: TranscriptLink;
|
|
2094
|
-
/** Optional normalized quality score supplied by a caller-owned evaluator. */
|
|
2095
|
-
readonly quality?: NormalizedQualityScore;
|
|
2096
|
-
/** Optional serializable evaluation payload supplied by a caller-owned evaluator. */
|
|
2097
|
-
readonly evaluation?: RunEvaluation;
|
|
2098
|
-
/** Termination condition that stopped the run, when the run ended by policy. */
|
|
2099
|
-
readonly termination?: TerminationStopRecord;
|
|
2100
|
-
}
|
|
2101
|
-
|
|
2102
|
-
/**
|
|
2103
|
-
* Successful coordination event emitted by Dogpile and persisted in traces.
|
|
2104
|
-
*
|
|
2105
|
-
* @remarks
|
|
2106
|
-
* `RunEvent` is the discriminated union stored in {@link Trace.events} and
|
|
2107
|
-
* used by low-level protocol emit callbacks. Switch on `type` to handle each
|
|
2108
|
-
* coordination moment exhaustively:
|
|
2109
|
-
*
|
|
2110
|
-
* - `role-assignment`: participant/role roster was established.
|
|
2111
|
-
* - `model-request`: one provider-neutral model request was started.
|
|
2112
|
-
* - `model-response`: one provider-neutral model response completed.
|
|
2113
|
-
* - `model-output-chunk`: one streaming model text delta arrived.
|
|
2114
|
-
* - `tool-call`: one runtime tool invocation was started.
|
|
2115
|
-
* - `tool-result`: one runtime tool invocation completed.
|
|
2116
|
-
* - `agent-turn`: one agent completed a prompt/response turn.
|
|
2117
|
-
* - `broadcast`: a broadcast round gathered independent contributions.
|
|
2118
|
-
* - `budget-stop`: a configured budget cap halted further model turns.
|
|
2119
|
-
* - `final`: the run completed and produced the final output.
|
|
2120
|
-
*
|
|
2121
|
-
* Every variant is JSON-serializable and includes `runId` plus an ISO-8601
|
|
2122
|
-
* `at` timestamp so callers can persist, render, or replay the event log
|
|
2123
|
-
* without SDK-owned storage.
|
|
2124
|
-
*
|
|
2125
|
-
* @example
|
|
2126
|
-
* ```ts
|
|
2127
|
-
* for await (const event of Dogpile.stream(options)) {
|
|
2128
|
-
* switch (event.type) {
|
|
2129
|
-
* case "agent-turn":
|
|
2130
|
-
* console.log(event.agentId, event.output);
|
|
2131
|
-
* break;
|
|
2132
|
-
* case "final":
|
|
2133
|
-
* console.log(event.output);
|
|
2134
|
-
* break;
|
|
2135
|
-
* }
|
|
2136
|
-
* }
|
|
2137
|
-
* ```
|
|
2138
|
-
*/
|
|
2139
|
-
export type RunEvent =
|
|
2140
|
-
| RoleAssignmentEvent
|
|
2141
|
-
| ModelRequestEvent
|
|
2142
|
-
| ModelResponseEvent
|
|
2143
|
-
| ModelOutputChunkEvent
|
|
2144
|
-
| ToolCallEvent
|
|
2145
|
-
| ToolResultEvent
|
|
2146
|
-
| TurnEvent
|
|
2147
|
-
| BroadcastEvent
|
|
2148
|
-
| BudgetStopEvent
|
|
2149
|
-
| FinalEvent;
|
|
2150
|
-
|
|
2151
|
-
/**
|
|
2152
|
-
* Model activity events yielded by `stream()` and persisted in traces when a
|
|
2153
|
-
* protocol exposes provider-call boundaries.
|
|
2154
|
-
*/
|
|
2155
|
-
export type ModelActivityEvent = ModelRequestEvent | ModelResponseEvent | ModelOutputChunkEvent;
|
|
1269
|
+
// Benchmark types: see src/types/benchmark.ts
|
|
1270
|
+
import type {
|
|
1271
|
+
BenchmarkBudget,
|
|
1272
|
+
BenchmarkCostAccounting,
|
|
1273
|
+
BenchmarkModelSettings,
|
|
1274
|
+
BenchmarkProtocolArtifact,
|
|
1275
|
+
BenchmarkProtocolScore,
|
|
1276
|
+
BenchmarkReproducibilityArtifact,
|
|
1277
|
+
BenchmarkRequiredArtifact,
|
|
1278
|
+
BenchmarkRunArtifact,
|
|
1279
|
+
BenchmarkRunnerConfig,
|
|
1280
|
+
BenchmarkScoreDimension,
|
|
1281
|
+
BenchmarkStreamingEventLog,
|
|
1282
|
+
BenchmarkTaskInput,
|
|
1283
|
+
ProtocolBenchmarkRunConfig
|
|
1284
|
+
} from "./types/benchmark.js";
|
|
1285
|
+
export type {
|
|
1286
|
+
BenchmarkBudget,
|
|
1287
|
+
BenchmarkCostAccounting,
|
|
1288
|
+
BenchmarkModelSettings,
|
|
1289
|
+
BenchmarkProtocolArtifact,
|
|
1290
|
+
BenchmarkProtocolScore,
|
|
1291
|
+
BenchmarkReproducibilityArtifact,
|
|
1292
|
+
BenchmarkRequiredArtifact,
|
|
1293
|
+
BenchmarkRunArtifact,
|
|
1294
|
+
BenchmarkRunnerConfig,
|
|
1295
|
+
BenchmarkScoreDimension,
|
|
1296
|
+
BenchmarkStreamingEventLog,
|
|
1297
|
+
BenchmarkTaskInput,
|
|
1298
|
+
ProtocolBenchmarkRunConfig
|
|
1299
|
+
};
|
|
1300
|
+
|
|
1301
|
+
// Events: see src/types/events.ts
|
|
1302
|
+
import type {
|
|
1303
|
+
AbortedEvent,
|
|
1304
|
+
AgentDecision,
|
|
1305
|
+
AgentParticipation,
|
|
1306
|
+
BroadcastContribution,
|
|
1307
|
+
BroadcastEvent,
|
|
1308
|
+
BudgetStopEvent,
|
|
1309
|
+
DelegateAgentDecision,
|
|
1310
|
+
FinalEvent,
|
|
1311
|
+
ModelActivityEvent,
|
|
1312
|
+
ModelOutputChunkEvent,
|
|
1313
|
+
ModelRequestEvent,
|
|
1314
|
+
ModelResponseEvent,
|
|
1315
|
+
ParticipateAgentDecision,
|
|
1316
|
+
RoleAssignmentEvent,
|
|
1317
|
+
RunEvent,
|
|
1318
|
+
StreamCompletionEvent,
|
|
1319
|
+
StreamErrorEvent,
|
|
1320
|
+
StreamEvent,
|
|
1321
|
+
StreamLifecycleEvent,
|
|
1322
|
+
StreamOutputEvent,
|
|
1323
|
+
SubRunBudgetClampedEvent,
|
|
1324
|
+
SubRunCompletedEvent,
|
|
1325
|
+
SubRunConcurrencyClampedEvent,
|
|
1326
|
+
SubRunFailedEvent,
|
|
1327
|
+
SubRunParentAbortedEvent,
|
|
1328
|
+
SubRunQueuedEvent,
|
|
1329
|
+
SubRunStartedEvent,
|
|
1330
|
+
ToolActivityEvent,
|
|
1331
|
+
ToolCallEvent,
|
|
1332
|
+
ToolResultEvent,
|
|
1333
|
+
TranscriptLink,
|
|
1334
|
+
TurnEvent
|
|
1335
|
+
} from "./types/events.js";
|
|
1336
|
+
export type {
|
|
1337
|
+
AbortedEvent,
|
|
1338
|
+
AgentDecision,
|
|
1339
|
+
AgentParticipation,
|
|
1340
|
+
DelegateAgentDecision,
|
|
1341
|
+
ParticipateAgentDecision,
|
|
1342
|
+
BroadcastContribution,
|
|
1343
|
+
BroadcastEvent,
|
|
1344
|
+
BudgetStopEvent,
|
|
1345
|
+
FinalEvent,
|
|
1346
|
+
ModelActivityEvent,
|
|
1347
|
+
ModelOutputChunkEvent,
|
|
1348
|
+
ModelRequestEvent,
|
|
1349
|
+
ModelResponseEvent,
|
|
1350
|
+
RoleAssignmentEvent,
|
|
1351
|
+
RunEvent,
|
|
1352
|
+
StreamCompletionEvent,
|
|
1353
|
+
StreamErrorEvent,
|
|
1354
|
+
StreamEvent,
|
|
1355
|
+
StreamLifecycleEvent,
|
|
1356
|
+
StreamOutputEvent,
|
|
1357
|
+
SubRunBudgetClampedEvent,
|
|
1358
|
+
SubRunCompletedEvent,
|
|
1359
|
+
SubRunConcurrencyClampedEvent,
|
|
1360
|
+
SubRunFailedEvent,
|
|
1361
|
+
SubRunParentAbortedEvent,
|
|
1362
|
+
SubRunQueuedEvent,
|
|
1363
|
+
SubRunStartedEvent,
|
|
1364
|
+
ToolActivityEvent,
|
|
1365
|
+
ToolCallEvent,
|
|
1366
|
+
ToolResultEvent,
|
|
1367
|
+
TranscriptLink,
|
|
1368
|
+
TurnEvent
|
|
1369
|
+
};
|
|
2156
1370
|
|
|
2157
|
-
/**
|
|
2158
|
-
* Tool activity events yielded by `stream()` and persisted in traces when a
|
|
2159
|
-
* protocol or caller-owned adapter invokes runtime tools.
|
|
2160
|
-
*/
|
|
2161
|
-
export type ToolActivityEvent = ToolCallEvent | ToolResultEvent;
|
|
2162
|
-
|
|
2163
|
-
/**
|
|
2164
|
-
* Lifecycle event yielded by `stream()`.
|
|
2165
|
-
*
|
|
2166
|
-
* These events describe workflow coordination state rather than model text.
|
|
2167
|
-
* Role assignment establishes the participant roster, while `budget-stop`
|
|
2168
|
-
* records a lifecycle halt before the terminal completion event.
|
|
2169
|
-
*/
|
|
2170
|
-
export type StreamLifecycleEvent = RoleAssignmentEvent | BudgetStopEvent;
|
|
2171
|
-
|
|
2172
|
-
/**
|
|
2173
|
-
* Output event yielded by `stream()`.
|
|
2174
|
-
*
|
|
2175
|
-
* These events carry generated agent output or grouped round output while a
|
|
2176
|
-
* workflow is still running.
|
|
2177
|
-
*/
|
|
2178
|
-
export type StreamOutputEvent = ModelActivityEvent | ToolActivityEvent | TurnEvent | BroadcastEvent;
|
|
2179
|
-
|
|
2180
|
-
/**
|
|
2181
|
-
* Error event yielded by `stream()` when execution rejects.
|
|
2182
|
-
*
|
|
2183
|
-
* @remarks
|
|
2184
|
-
* Stream errors are emitted before {@link StreamHandle.result} rejects so UIs
|
|
2185
|
-
* and log collectors can record a terminal failure without wrapping the result
|
|
2186
|
-
* promise. The error payload is JSON-serializable and intentionally omits
|
|
2187
|
-
* runtime-specific values such as `Error.stack`.
|
|
2188
|
-
*/
|
|
2189
|
-
export interface StreamErrorEvent {
|
|
2190
|
-
/** Discriminant for stream event handling. */
|
|
2191
|
-
readonly type: "error";
|
|
2192
|
-
/** Stable run id when known; empty when failure happened before protocol startup. */
|
|
2193
|
-
readonly runId: string;
|
|
2194
|
-
/** ISO-8601 event timestamp. */
|
|
2195
|
-
readonly at: string;
|
|
2196
|
-
/** Error name when available. */
|
|
2197
|
-
readonly name: string;
|
|
2198
|
-
/** Human-readable error message. */
|
|
2199
|
-
readonly message: string;
|
|
2200
|
-
/** Optional serializable diagnostics supplied by the SDK. */
|
|
2201
|
-
readonly detail?: JsonObject;
|
|
2202
|
-
}
|
|
2203
|
-
|
|
2204
|
-
/**
|
|
2205
|
-
* Completion event yielded by `stream()` after successful execution.
|
|
2206
|
-
*/
|
|
2207
|
-
export type StreamCompletionEvent = FinalEvent;
|
|
2208
|
-
|
|
2209
|
-
/**
|
|
2210
|
-
* Public streaming event union returned by `stream()`.
|
|
2211
|
-
*
|
|
2212
|
-
* @remarks
|
|
2213
|
-
* The union is grouped into lifecycle, output, error, and completion families:
|
|
2214
|
-
*
|
|
2215
|
-
* - lifecycle: {@link StreamLifecycleEvent}
|
|
2216
|
-
* - output: {@link StreamOutputEvent}
|
|
2217
|
-
* - error: {@link StreamErrorEvent}
|
|
2218
|
-
* - completion: {@link StreamCompletionEvent}
|
|
2219
|
-
*
|
|
2220
|
-
* Successful stream events are also persisted as {@link RunEvent} values in the
|
|
2221
|
-
* completed trace. `error` is stream-only because a failed run has no completed
|
|
2222
|
-
* {@link RunResult} trace to return.
|
|
2223
|
-
*/
|
|
2224
|
-
export type StreamEvent = StreamLifecycleEvent | StreamOutputEvent | StreamErrorEvent | StreamCompletionEvent;
|
|
2225
1371
|
|
|
2226
1372
|
/**
|
|
2227
1373
|
* Lifecycle status for a live {@link StreamHandle}.
|
|
@@ -2262,7 +1408,7 @@ export interface TranscriptEntry {
|
|
|
2262
1408
|
/** Text produced by the agent. */
|
|
2263
1409
|
readonly output: string;
|
|
2264
1410
|
/** Optional structured role/participation decision parsed from model output. */
|
|
2265
|
-
readonly decision?: AgentDecision;
|
|
1411
|
+
readonly decision?: AgentDecision | readonly DelegateAgentDecision[];
|
|
2266
1412
|
/** Ordered runtime tool calls and results requested during this turn. */
|
|
2267
1413
|
readonly toolCalls?: readonly TranscriptToolCall[];
|
|
2268
1414
|
}
|
|
@@ -2425,6 +1571,17 @@ export interface Trace {
|
|
|
2425
1571
|
readonly providerCalls: readonly ReplayTraceProviderCall[];
|
|
2426
1572
|
/** Final output artifact for replay consumers. */
|
|
2427
1573
|
readonly finalOutput: ReplayTraceFinalOutput;
|
|
1574
|
+
/** Internal hand-off for fail-fast coordinator child failure handling. */
|
|
1575
|
+
readonly triggeringFailureForAbortMode?: {
|
|
1576
|
+
readonly childRunId: string;
|
|
1577
|
+
readonly intent: string;
|
|
1578
|
+
readonly error: {
|
|
1579
|
+
readonly code: string;
|
|
1580
|
+
readonly message: string;
|
|
1581
|
+
readonly detail?: { readonly reason?: string };
|
|
1582
|
+
};
|
|
1583
|
+
readonly partialCost: { readonly usd: number };
|
|
1584
|
+
};
|
|
2428
1585
|
/**
|
|
2429
1586
|
* Ordered coordination and lifecycle events.
|
|
2430
1587
|
*
|
|
@@ -2650,8 +1807,48 @@ export interface DogpileOptions extends BudgetCostTierOptions {
|
|
|
2650
1807
|
readonly seed?: string | number;
|
|
2651
1808
|
/** Optional caller cancellation signal passed to provider-facing model requests. */
|
|
2652
1809
|
readonly signal?: AbortSignal;
|
|
1810
|
+
/**
|
|
1811
|
+
* Maximum coordinator → sub-run recursion depth.
|
|
1812
|
+
*
|
|
1813
|
+
* Defaults to 4. Per-run values can only LOWER the engine ceiling; raising
|
|
1814
|
+
* is silently capped via
|
|
1815
|
+
* `effectiveMaxDepth = Math.min(engineMaxDepth, runMaxDepth ?? Infinity)`.
|
|
1816
|
+
* Depth overflow throws `DogpileError({ code: "invalid-configuration",
|
|
1817
|
+
* detail: { kind: "delegate-validation", reason: "depth-overflow" } })`.
|
|
1818
|
+
*/
|
|
1819
|
+
readonly maxDepth?: number;
|
|
1820
|
+
/**
|
|
1821
|
+
* Maximum delegated child runs that may execute in parallel.
|
|
1822
|
+
*
|
|
1823
|
+
* Defaults to 4. Per-run and per-decision values can only lower the engine
|
|
1824
|
+
* ceiling; the effective value is `min(engine, run ?? Infinity, decision ?? Infinity)`.
|
|
1825
|
+
*/
|
|
1826
|
+
readonly maxConcurrentChildren?: number;
|
|
1827
|
+
/**
|
|
1828
|
+
* Fallback timeout (milliseconds) applied to delegated sub-runs when neither
|
|
1829
|
+
* the parent's `budget.timeoutMs` nor the decision-level
|
|
1830
|
+
* `decision.budget.timeoutMs` specifies one (BUDGET-02 / D-14).
|
|
1831
|
+
*
|
|
1832
|
+
* Precedence (most specific wins):
|
|
1833
|
+
* `decision.budget.timeoutMs` > parent's remaining deadline (when parent has
|
|
1834
|
+
* `budget.timeoutMs`) > `defaultSubRunTimeoutMs` > undefined.
|
|
1835
|
+
*
|
|
1836
|
+
* Default: `undefined` (preserves the "no sub-run timeout" posture).
|
|
1837
|
+
*/
|
|
1838
|
+
readonly defaultSubRunTimeoutMs?: number;
|
|
1839
|
+
/**
|
|
1840
|
+
* Controls how coordinator runs react after a real delegated child failure.
|
|
1841
|
+
*
|
|
1842
|
+
* Defaults to `"continue"`, which re-issues the coordinator plan turn with
|
|
1843
|
+
* structured failure context. `"abort"` skips that follow-up plan turn and
|
|
1844
|
+
* records the triggering child failure for the unhandled-failure throw path.
|
|
1845
|
+
*/
|
|
1846
|
+
readonly onChildFailure?: OnChildFailureMode;
|
|
2653
1847
|
}
|
|
2654
1848
|
|
|
1849
|
+
/** Coordinator behavior after a real child failure in a delegated dispatch wave. */
|
|
1850
|
+
export type OnChildFailureMode = "continue" | "abort";
|
|
1851
|
+
|
|
2655
1852
|
/**
|
|
2656
1853
|
* Low-level engine configuration for reusable protocol execution.
|
|
2657
1854
|
*
|
|
@@ -2714,6 +1911,63 @@ export interface EngineOptions {
|
|
|
2714
1911
|
readonly seed?: string | number;
|
|
2715
1912
|
/** Optional caller cancellation signal passed to provider-facing model requests. */
|
|
2716
1913
|
readonly signal?: AbortSignal;
|
|
1914
|
+
/**
|
|
1915
|
+
* Maximum coordinator → sub-run recursion depth ceiling.
|
|
1916
|
+
*
|
|
1917
|
+
* Defaults to 4. Per-run lowering happens at `engine.run` / `engine.stream`
|
|
1918
|
+
* call sites via {@link RunCallOptions.maxDepth}; per-run can only lower this
|
|
1919
|
+
* ceiling. Depth overflow throws `DogpileError({ code: "invalid-configuration",
|
|
1920
|
+
* detail: { kind: "delegate-validation", reason: "depth-overflow" } })`.
|
|
1921
|
+
*/
|
|
1922
|
+
readonly maxDepth?: number;
|
|
1923
|
+
/**
|
|
1924
|
+
* Maximum delegated child runs that may execute in parallel.
|
|
1925
|
+
*
|
|
1926
|
+
* Defaults to 4. Per-run lowering happens at `engine.run` / `engine.stream`
|
|
1927
|
+
* call sites via {@link RunCallOptions.maxConcurrentChildren}.
|
|
1928
|
+
*/
|
|
1929
|
+
readonly maxConcurrentChildren?: number;
|
|
1930
|
+
/**
|
|
1931
|
+
* Fallback timeout (milliseconds) applied to delegated sub-runs when neither
|
|
1932
|
+
* the parent's `budget.timeoutMs` nor the decision-level
|
|
1933
|
+
* `decision.budget.timeoutMs` specifies one (BUDGET-02 / D-14).
|
|
1934
|
+
*
|
|
1935
|
+
* Precedence (most specific wins):
|
|
1936
|
+
* `decision.budget.timeoutMs` > parent's remaining deadline (when parent has
|
|
1937
|
+
* `budget.timeoutMs`) > `defaultSubRunTimeoutMs` > undefined.
|
|
1938
|
+
*
|
|
1939
|
+
* Default: `undefined` (preserves the "no sub-run timeout" posture).
|
|
1940
|
+
*/
|
|
1941
|
+
readonly defaultSubRunTimeoutMs?: number;
|
|
1942
|
+
/**
|
|
1943
|
+
* Controls how coordinator runs react after a real delegated child failure.
|
|
1944
|
+
*
|
|
1945
|
+
* Defaults to `"continue"`. `"abort"` skips the follow-up coordinator plan
|
|
1946
|
+
* turn and records the triggering child failure for fail-fast callers.
|
|
1947
|
+
*/
|
|
1948
|
+
readonly onChildFailure?: OnChildFailureMode;
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
/**
|
|
1952
|
+
* Per-call overrides accepted by {@link Engine.run} and {@link Engine.stream}.
|
|
1953
|
+
*
|
|
1954
|
+
* @remarks
|
|
1955
|
+
* Only fields that should be controllable per-mission live here. Today the
|
|
1956
|
+
* fields are controls that can only LOWER the engine's ceiling.
|
|
1957
|
+
*/
|
|
1958
|
+
export interface RunCallOptions {
|
|
1959
|
+
/**
|
|
1960
|
+
* Per-run maximum recursion depth. Cannot raise the engine's ceiling — the
|
|
1961
|
+
* effective value is `Math.min(engine.maxDepth ?? 4, runOptions.maxDepth ?? Infinity)`.
|
|
1962
|
+
*/
|
|
1963
|
+
readonly maxDepth?: number;
|
|
1964
|
+
/**
|
|
1965
|
+
* Per-run delegated child concurrency ceiling. Cannot raise the engine's
|
|
1966
|
+
* ceiling.
|
|
1967
|
+
*/
|
|
1968
|
+
readonly maxConcurrentChildren?: number;
|
|
1969
|
+
/** Per-run child-failure behavior. Overrides the engine default. */
|
|
1970
|
+
readonly onChildFailure?: OnChildFailureMode;
|
|
2717
1971
|
}
|
|
2718
1972
|
|
|
2719
1973
|
/**
|
|
@@ -2793,7 +2047,7 @@ export interface StreamSubscription {
|
|
|
2793
2047
|
*/
|
|
2794
2048
|
export interface Engine {
|
|
2795
2049
|
/** Execute a mission to completion and return the final result. */
|
|
2796
|
-
run(intent: string): Promise<RunResult>;
|
|
2050
|
+
run(intent: string, options?: RunCallOptions): Promise<RunResult>;
|
|
2797
2051
|
/** Stream a mission's events while preserving access to the final result. */
|
|
2798
|
-
stream(intent: string): StreamHandle;
|
|
2052
|
+
stream(intent: string, options?: RunCallOptions): StreamHandle;
|
|
2799
2053
|
}
|