@clearideas/agent-runtime-contracts 0.9.0 → 1.0.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/NOTICE +2 -2
- package/dist/index.d.ts +243 -10
- package/dist/index.js +142 -0
- package/package.json +1 -1
package/NOTICE
CHANGED
|
@@ -3,6 +3,6 @@ Copyright 2026 Clear Ideas Incorporated
|
|
|
3
3
|
|
|
4
4
|
Clear Ideas is a trademark of Clear Ideas Incorporated.
|
|
5
5
|
|
|
6
|
-
The documentation site includes @clearideas/analytics 1.
|
|
6
|
+
The documentation site includes @clearideas/consent-analytics 0.1.0-rc.1, distributed
|
|
7
7
|
under the MIT License. Its license text is available at
|
|
8
|
-
docs/public/assets/analytics/LICENSE.clearideas-analytics.txt.
|
|
8
|
+
docs/public/assets/analytics/LICENSE.clearideas-consent-analytics.txt.
|
package/dist/index.d.ts
CHANGED
|
@@ -465,6 +465,13 @@ export interface ExecutionPolicies {
|
|
|
465
465
|
outputRepair?: OutputRepairPolicy;
|
|
466
466
|
/** continue: record the error as the step output and run the next step. */
|
|
467
467
|
onError?: "fail" | "continue";
|
|
468
|
+
/**
|
|
469
|
+
* What a step failure that is not fatal does to the run. `pause` (default)
|
|
470
|
+
* suspends it with kind `awaiting-host`, keeping its progress, resumable
|
|
471
|
+
* once the cause is fixed; `fail` ends the attempt as failed. Run-level:
|
|
472
|
+
* set it on the host or the manifest, not on a step.
|
|
473
|
+
*/
|
|
474
|
+
onFailure?: "pause" | "fail";
|
|
468
475
|
}
|
|
469
476
|
export interface AgentStepBase {
|
|
470
477
|
id: string;
|
|
@@ -592,18 +599,168 @@ export interface AgentManifest {
|
|
|
592
599
|
steps: AgentStep[];
|
|
593
600
|
/** Manifest-wide execution policy defaults; steps may override them. */
|
|
594
601
|
policies?: ExecutionPolicies;
|
|
595
|
-
limits?:
|
|
596
|
-
maxSteps?: number;
|
|
597
|
-
maxMessagesPerPrompt?: number;
|
|
598
|
-
maxInputBytes?: number;
|
|
599
|
-
maxOutputBytes?: number;
|
|
600
|
-
/** Total tool calls per prompt step execution, across model turns and resumes. */
|
|
601
|
-
maxToolCallsPerIteration?: number;
|
|
602
|
-
providerTimeoutMs?: number;
|
|
603
|
-
};
|
|
602
|
+
limits?: AgentManifestLimits;
|
|
604
603
|
metadata?: JsonObject;
|
|
605
604
|
extensions?: JsonObject;
|
|
606
605
|
}
|
|
606
|
+
/**
|
|
607
|
+
* Sandbox usage for one run. A manifest or a resume request may set these;
|
|
608
|
+
* the host's sandbox configuration is the ceiling and the default.
|
|
609
|
+
*/
|
|
610
|
+
export interface RunSandboxUsageLimits {
|
|
611
|
+
maxCommands?: number;
|
|
612
|
+
maxSeconds?: number;
|
|
613
|
+
commandTimeoutMs?: number;
|
|
614
|
+
maxCommandTimeoutMs?: number;
|
|
615
|
+
maxStdoutBytes?: number;
|
|
616
|
+
maxStderrBytes?: number;
|
|
617
|
+
maxOutputFiles?: number;
|
|
618
|
+
maxOutputBytes?: number;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Limits that stop a runaway run. `DEFAULT_RUN_LIMITS` applies to every run;
|
|
622
|
+
* the host's defaults, the manifest, and `RunRequest.limits` replace values,
|
|
623
|
+
* and the host's `enforcedLimits` cap them. Reaching one suspends the run
|
|
624
|
+
* with kind `awaiting-host`; it resumes once a higher limit is granted.
|
|
625
|
+
*
|
|
626
|
+
* A step execution is one run of a step that does work: a top-level step, or
|
|
627
|
+
* one loop iteration's child. A loop itself is bounded by the run's limits
|
|
628
|
+
* and `maxLoopIterations`.
|
|
629
|
+
*/
|
|
630
|
+
export interface RunLimits {
|
|
631
|
+
/** Model tokens reported across the run. */
|
|
632
|
+
maxTotalTokens?: number;
|
|
633
|
+
/** Model tokens reported by one step execution. */
|
|
634
|
+
maxStepTokens?: number;
|
|
635
|
+
/** Estimated cost adapters report (`ModelUsage.estimatedCost`) across the run. */
|
|
636
|
+
maxEstimatedCost?: number;
|
|
637
|
+
/** Active execution time across all attempts. */
|
|
638
|
+
maxRunActiveMs?: number;
|
|
639
|
+
/** Active execution time of one step execution, across attempts. */
|
|
640
|
+
maxStepActiveMs?: number;
|
|
641
|
+
/**
|
|
642
|
+
* Recoveries: resumes after a failure, an interruption, a takeover, or an
|
|
643
|
+
* error block. Resumes that answer an approval, a child run, a budget, a
|
|
644
|
+
* granted limit, or a pause do not count.
|
|
645
|
+
*/
|
|
646
|
+
maxRecoveries?: number;
|
|
647
|
+
/** Consecutive recoveries that make no progress (no new checkpoint): a crash loop. */
|
|
648
|
+
maxResumesWithoutProgress?: number;
|
|
649
|
+
/** Model requests made by one prompt step execution. */
|
|
650
|
+
maxTurnsPerPrompt?: number;
|
|
651
|
+
/** Iterations of one loop step execution. */
|
|
652
|
+
maxLoopIterations?: number;
|
|
653
|
+
/** Artifacts recorded by the run. */
|
|
654
|
+
maxArtifacts?: number;
|
|
655
|
+
/** Bytes of artifacts recorded by the run. */
|
|
656
|
+
maxArtifactBytes?: number;
|
|
657
|
+
/** Serialized size of one checkpoint. */
|
|
658
|
+
maxCheckpointBytes?: number;
|
|
659
|
+
sandbox?: RunSandboxUsageLimits;
|
|
660
|
+
}
|
|
661
|
+
export interface AgentManifestLimits extends RunLimits {
|
|
662
|
+
maxSteps?: number;
|
|
663
|
+
maxMessagesPerPrompt?: number;
|
|
664
|
+
maxInputBytes?: number;
|
|
665
|
+
maxOutputBytes?: number;
|
|
666
|
+
/** Total tool calls per prompt step execution, across model turns and resumes. */
|
|
667
|
+
maxToolCallsPerIteration?: number;
|
|
668
|
+
providerTimeoutMs?: number;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Anti-runaway limits every run has unless its host or manifest sets others:
|
|
672
|
+
* high enough to be irrelevant to normal runs. `maxStepTokens` and
|
|
673
|
+
* `maxEstimatedCost` have no default.
|
|
674
|
+
*/
|
|
675
|
+
export declare const DEFAULT_RUN_LIMITS: {
|
|
676
|
+
readonly maxTotalTokens: 25000000;
|
|
677
|
+
readonly maxRunActiveMs: number;
|
|
678
|
+
readonly maxStepActiveMs: number;
|
|
679
|
+
readonly maxRecoveries: 100;
|
|
680
|
+
readonly maxResumesWithoutProgress: 10;
|
|
681
|
+
readonly maxTurnsPerPrompt: 500;
|
|
682
|
+
readonly maxLoopIterations: 10000;
|
|
683
|
+
readonly maxArtifacts: 10000;
|
|
684
|
+
readonly maxArtifactBytes: number;
|
|
685
|
+
readonly maxCheckpointBytes: number;
|
|
686
|
+
};
|
|
687
|
+
export declare const runSandboxUsageLimitsSchema: z.ZodType<RunSandboxUsageLimits>;
|
|
688
|
+
export declare const runLimitsSchema: z.ZodType<RunLimits>;
|
|
689
|
+
/**
|
|
690
|
+
* Durable usage of one run across its attempts, carried by every checkpoint.
|
|
691
|
+
* Limits are checked against it.
|
|
692
|
+
*/
|
|
693
|
+
export interface RunLedger {
|
|
694
|
+
/** Model tokens reported in the run's transcript, less inherited ones. */
|
|
695
|
+
tokens: number;
|
|
696
|
+
/** Active execution time summed across attempts. */
|
|
697
|
+
activeMs: number;
|
|
698
|
+
/** Estimated cost adapters reported, less inherited cost. */
|
|
699
|
+
estimatedCost?: number;
|
|
700
|
+
/** The step execution that is running, with its tokens and active time. */
|
|
701
|
+
step?: {
|
|
702
|
+
key: string;
|
|
703
|
+
tokens: number;
|
|
704
|
+
activeMs: number;
|
|
705
|
+
};
|
|
706
|
+
/** Recoveries so far: resumes after a failure, interruption, takeover, or error block. */
|
|
707
|
+
recoveries?: number;
|
|
708
|
+
artifacts: {
|
|
709
|
+
count: number;
|
|
710
|
+
bytes: number;
|
|
711
|
+
};
|
|
712
|
+
/** Cumulative run-sandbox usage. */
|
|
713
|
+
sandbox?: {
|
|
714
|
+
commands: number;
|
|
715
|
+
seconds: number;
|
|
716
|
+
};
|
|
717
|
+
/**
|
|
718
|
+
* The sequence of the latest checkpoint that recorded progress. Copies the
|
|
719
|
+
* runtime commits to make facts durable (a resume, a block) do not move it.
|
|
720
|
+
*/
|
|
721
|
+
progress?: number;
|
|
722
|
+
/** Consecutive resumes that made no progress, and the progress point they resumed. */
|
|
723
|
+
stalledResumes?: {
|
|
724
|
+
count: number;
|
|
725
|
+
sequence: number;
|
|
726
|
+
};
|
|
727
|
+
/** Limits granted through `RunRequest.limits`; they apply to later attempts too. */
|
|
728
|
+
granted?: RunLimits;
|
|
729
|
+
/**
|
|
730
|
+
* For a run seeded from another run's checkpoint: the usage its inherited
|
|
731
|
+
* transcript and artifacts represent, which does not count against this
|
|
732
|
+
* run's limits.
|
|
733
|
+
*/
|
|
734
|
+
inherited?: {
|
|
735
|
+
tokens: number;
|
|
736
|
+
estimatedCost?: number;
|
|
737
|
+
artifacts: {
|
|
738
|
+
count: number;
|
|
739
|
+
bytes: number;
|
|
740
|
+
};
|
|
741
|
+
};
|
|
742
|
+
/**
|
|
743
|
+
* Present on the checkpoint committed when the run was blocked (suspended
|
|
744
|
+
* with kind `awaiting-host`): why, so a host can act on it.
|
|
745
|
+
*/
|
|
746
|
+
blocked?: RunBlocked;
|
|
747
|
+
}
|
|
748
|
+
/** Why a run is waiting for its host: a limit was reached, or an error occurred. */
|
|
749
|
+
export interface RunBlocked {
|
|
750
|
+
cause: "limit" | "error";
|
|
751
|
+
/** The limit name (for example `maxTotalTokens`) or the error code. */
|
|
752
|
+
code: string;
|
|
753
|
+
message: string;
|
|
754
|
+
/** For limits: usage and the limit value when the run was blocked. */
|
|
755
|
+
used?: number;
|
|
756
|
+
value?: number;
|
|
757
|
+
/** For errors: whether retrying may succeed, and classified details. */
|
|
758
|
+
retryable?: boolean;
|
|
759
|
+
details?: JsonObject;
|
|
760
|
+
stepId?: string;
|
|
761
|
+
at: string;
|
|
762
|
+
}
|
|
763
|
+
export declare const runLedgerSchema: z.ZodType<RunLedger>;
|
|
607
764
|
export declare const agentMessagesDeclarationSchema: z.ZodType<AgentMessagesDeclaration>;
|
|
608
765
|
export declare const agentManifestSchema: z.ZodType<AgentManifest>;
|
|
609
766
|
export interface AgentRunManifest {
|
|
@@ -679,9 +836,57 @@ export interface RunCheckpoint {
|
|
|
679
836
|
budget?: RunBudgetState;
|
|
680
837
|
/** The run's effective conversation history, when the manifest declares messages. */
|
|
681
838
|
messages?: RunMessagesState;
|
|
839
|
+
/** Durable usage across attempts (contract 1.1). */
|
|
840
|
+
ledger?: RunLedger;
|
|
841
|
+
/**
|
|
842
|
+
* Per workspace alias: the opaque token the workspace store returned at the
|
|
843
|
+
* latest step commit point, handed back when a run restarts from here.
|
|
844
|
+
*/
|
|
845
|
+
workspaces?: Record<string, RunCheckpointWorkspace>;
|
|
846
|
+
/** Per read-only workspace alias: the input version token at run start. */
|
|
847
|
+
inputs?: Record<string, {
|
|
848
|
+
token: string;
|
|
849
|
+
}>;
|
|
850
|
+
/** Fingerprints that decide which manifest changes a resume may accept. */
|
|
851
|
+
fingerprints?: RunCheckpointFingerprints;
|
|
852
|
+
/** Present on a checkpoint committed when a step completed: a restart point. */
|
|
853
|
+
boundary?: RunCheckpointBoundary;
|
|
682
854
|
createdAt: string;
|
|
683
855
|
metadata?: JsonObject;
|
|
684
856
|
}
|
|
857
|
+
/** Checkpoint contract versions this release reads; it writes the latest. */
|
|
858
|
+
export declare const RUN_CHECKPOINT_CONTRACT_VERSIONS: readonly ["1.0", "1.1"];
|
|
859
|
+
export declare const RUN_CHECKPOINT_CONTRACT_VERSION: "1.1";
|
|
860
|
+
/** One file change copied back to a workspace store. */
|
|
861
|
+
export interface WorkspaceChange {
|
|
862
|
+
path: string;
|
|
863
|
+
action: "created" | "modified" | "deleted";
|
|
864
|
+
size?: number;
|
|
865
|
+
sha256?: string;
|
|
866
|
+
}
|
|
867
|
+
export interface RunCheckpointWorkspace {
|
|
868
|
+
/** The opaque token the store returned at the latest step commit point. */
|
|
869
|
+
token?: string;
|
|
870
|
+
/** The step whose completion produced the token. */
|
|
871
|
+
stepPath?: string;
|
|
872
|
+
/** The checkpoint that first recorded the token. */
|
|
873
|
+
sequence?: number;
|
|
874
|
+
/** Changes copied back since that commit point, for the next one. */
|
|
875
|
+
pending?: WorkspaceChange[];
|
|
876
|
+
}
|
|
877
|
+
export interface RunCheckpointFingerprints {
|
|
878
|
+
/** Manifest-wide fields that completed steps depend on. */
|
|
879
|
+
global: string;
|
|
880
|
+
/** One per top-level step, in manifest order. */
|
|
881
|
+
steps: string[];
|
|
882
|
+
}
|
|
883
|
+
export interface RunCheckpointBoundary {
|
|
884
|
+
/** The step that completed: a top-level step id, or a nested step path. */
|
|
885
|
+
stepPath: string;
|
|
886
|
+
stepIndex: number;
|
|
887
|
+
/** The completed execution, for example `each[2]/fetch`. */
|
|
888
|
+
executionKey?: string;
|
|
889
|
+
}
|
|
685
890
|
export interface RunError {
|
|
686
891
|
code: string;
|
|
687
892
|
message: string;
|
|
@@ -1413,11 +1618,39 @@ export declare const runCheckpointSchema: z.ZodObject<{
|
|
|
1413
1618
|
continuation: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
1414
1619
|
budget: z.ZodOptional<z.ZodType<RunBudgetState, unknown, z.core.$ZodTypeInternals<RunBudgetState, unknown>>>;
|
|
1415
1620
|
messages: z.ZodOptional<z.ZodLazy<z.ZodType<RunMessagesState, unknown, z.core.$ZodTypeInternals<RunMessagesState, unknown>>>>;
|
|
1621
|
+
ledger: z.ZodOptional<z.ZodType<RunLedger, unknown, z.core.$ZodTypeInternals<RunLedger, unknown>>>;
|
|
1622
|
+
workspaces: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1623
|
+
token: z.ZodOptional<z.ZodString>;
|
|
1624
|
+
stepPath: z.ZodOptional<z.ZodString>;
|
|
1625
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
1626
|
+
pending: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1627
|
+
path: z.ZodString;
|
|
1628
|
+
action: z.ZodEnum<{
|
|
1629
|
+
created: "created";
|
|
1630
|
+
deleted: "deleted";
|
|
1631
|
+
modified: "modified";
|
|
1632
|
+
}>;
|
|
1633
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
1634
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
1635
|
+
}, z.core.$strict>>>;
|
|
1636
|
+
}, z.core.$strict>>>;
|
|
1637
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1638
|
+
token: z.ZodString;
|
|
1639
|
+
}, z.core.$strict>>>;
|
|
1640
|
+
fingerprints: z.ZodOptional<z.ZodObject<{
|
|
1641
|
+
global: z.ZodString;
|
|
1642
|
+
steps: z.ZodArray<z.ZodString>;
|
|
1643
|
+
}, z.core.$strict>>;
|
|
1644
|
+
boundary: z.ZodOptional<z.ZodObject<{
|
|
1645
|
+
stepPath: z.ZodString;
|
|
1646
|
+
stepIndex: z.ZodNumber;
|
|
1647
|
+
executionKey: z.ZodOptional<z.ZodString>;
|
|
1648
|
+
}, z.core.$strict>>;
|
|
1416
1649
|
createdAt: z.ZodISODateTime;
|
|
1417
1650
|
metadata: z.ZodOptional<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
1418
1651
|
}, z.core.$strict>;
|
|
1419
1652
|
export declare const parseRunCheckpoint: (input: unknown) => RunCheckpoint;
|
|
1420
|
-
export type RunEventType = "run.started" | "run.resumed" | "run.completed" | "run.failed" | "run.cancelled" | "run.suspended" | "run.interrupted" | "run.heartbeat" | "step.started" | "step.skipped" | "step.completed" | "step.failed" | "checkpoint.saved" | "loop.iteration.started" | "loop.iteration.completed" | "loop.iteration.skipped" | "loop.goal.met" | "approval.requested" | "approval.resolved" | "webhook.attempt.started" | "webhook.attempt.completed" | "webhook.retry.scheduled" | "code.execution.started" | "code.execution.completed" | "workspace.bound" | "sandbox.opened" | "sandbox.command.started" | "sandbox.command.completed" | "sandbox.closed" | "sub-run.started" | "sub-run.completed" | "model.started" | "model.text.delta" | "model.reasoning.delta" | "model.tool.requested" | "model.tool.started" | "model.tool.completed" | "model.usage" | "model.completed" | "model.retry" | "context.reduced" | "artifact.created" | "diagnostic";
|
|
1653
|
+
export type RunEventType = "run.started" | "run.resumed" | "run.completed" | "run.failed" | "run.cancelled" | "run.suspended" | "run.interrupted" | "run.heartbeat" | "step.started" | "step.skipped" | "step.completed" | "step.failed" | "checkpoint.saved" | "loop.iteration.started" | "loop.iteration.completed" | "loop.iteration.skipped" | "loop.goal.met" | "approval.requested" | "approval.resolved" | "webhook.attempt.started" | "webhook.attempt.completed" | "webhook.retry.scheduled" | "code.execution.started" | "code.execution.completed" | "workspace.bound" | "sandbox.opened" | "sandbox.command.started" | "sandbox.command.completed" | "sandbox.closed" | "workspace.committed" | "sub-run.started" | "sub-run.completed" | "model.started" | "model.text.delta" | "model.reasoning.delta" | "model.tool.requested" | "model.tool.started" | "model.tool.completed" | "model.usage" | "model.completed" | "model.retry" | "context.reduced" | "artifact.created" | "diagnostic";
|
|
1421
1654
|
export interface RunEvent {
|
|
1422
1655
|
id: string;
|
|
1423
1656
|
runId: string;
|
package/dist/index.js
CHANGED
|
@@ -205,6 +205,7 @@ export const executionPoliciesSchema = z.strictObject({
|
|
|
205
205
|
})
|
|
206
206
|
.optional(),
|
|
207
207
|
onError: z.enum(["fail", "continue"]).optional(),
|
|
208
|
+
onFailure: z.enum(["pause", "fail"]).optional(),
|
|
208
209
|
});
|
|
209
210
|
/** Policy fields that only a prompt step can use. */
|
|
210
211
|
export const PROMPT_ONLY_POLICY_FIELDS = [
|
|
@@ -487,6 +488,104 @@ export const agentStepSchema = z.lazy(() => z.discriminatedUnion("type", [
|
|
|
487
488
|
sandbox: z.enum(["run", "step"]).optional(),
|
|
488
489
|
}),
|
|
489
490
|
]));
|
|
491
|
+
/**
|
|
492
|
+
* Anti-runaway limits every run has unless its host or manifest sets others:
|
|
493
|
+
* high enough to be irrelevant to normal runs. `maxStepTokens` and
|
|
494
|
+
* `maxEstimatedCost` have no default.
|
|
495
|
+
*/
|
|
496
|
+
export const DEFAULT_RUN_LIMITS = {
|
|
497
|
+
maxTotalTokens: 25_000_000,
|
|
498
|
+
maxRunActiveMs: 24 * 60 * 60 * 1_000,
|
|
499
|
+
maxStepActiveMs: 4 * 60 * 60 * 1_000,
|
|
500
|
+
maxRecoveries: 100,
|
|
501
|
+
maxResumesWithoutProgress: 10,
|
|
502
|
+
maxTurnsPerPrompt: 500,
|
|
503
|
+
maxLoopIterations: 10_000,
|
|
504
|
+
maxArtifacts: 10_000,
|
|
505
|
+
maxArtifactBytes: 10 * 1024 * 1024 * 1024,
|
|
506
|
+
maxCheckpointBytes: 64 * 1024 * 1024,
|
|
507
|
+
};
|
|
508
|
+
const limitValue = z.number().int().positive().safe();
|
|
509
|
+
export const runSandboxUsageLimitsSchema = z.strictObject({
|
|
510
|
+
maxCommands: limitValue.optional(),
|
|
511
|
+
maxSeconds: z.number().positive().optional(),
|
|
512
|
+
commandTimeoutMs: limitValue.optional(),
|
|
513
|
+
maxCommandTimeoutMs: limitValue.optional(),
|
|
514
|
+
maxStdoutBytes: limitValue.optional(),
|
|
515
|
+
maxStderrBytes: limitValue.optional(),
|
|
516
|
+
maxOutputFiles: limitValue.optional(),
|
|
517
|
+
maxOutputBytes: limitValue.optional(),
|
|
518
|
+
});
|
|
519
|
+
const runLimitsShape = {
|
|
520
|
+
maxTotalTokens: limitValue.optional(),
|
|
521
|
+
maxStepTokens: limitValue.optional(),
|
|
522
|
+
maxEstimatedCost: z.number().positive().optional(),
|
|
523
|
+
maxRunActiveMs: limitValue.optional(),
|
|
524
|
+
maxStepActiveMs: limitValue.optional(),
|
|
525
|
+
maxRecoveries: limitValue.optional(),
|
|
526
|
+
maxResumesWithoutProgress: limitValue.optional(),
|
|
527
|
+
maxTurnsPerPrompt: limitValue.optional(),
|
|
528
|
+
maxLoopIterations: limitValue.optional(),
|
|
529
|
+
maxArtifacts: limitValue.optional(),
|
|
530
|
+
maxArtifactBytes: limitValue.optional(),
|
|
531
|
+
maxCheckpointBytes: limitValue.optional(),
|
|
532
|
+
sandbox: runSandboxUsageLimitsSchema.optional(),
|
|
533
|
+
};
|
|
534
|
+
export const runLimitsSchema = z.strictObject(runLimitsShape);
|
|
535
|
+
export const runLedgerSchema = z.strictObject({
|
|
536
|
+
tokens: z.number().int().nonnegative().safe(),
|
|
537
|
+
activeMs: z.number().nonnegative(),
|
|
538
|
+
estimatedCost: z.number().nonnegative().optional(),
|
|
539
|
+
step: z
|
|
540
|
+
.strictObject({
|
|
541
|
+
key: z.string().min(1),
|
|
542
|
+
tokens: z.number().int().nonnegative().safe(),
|
|
543
|
+
activeMs: z.number().nonnegative(),
|
|
544
|
+
})
|
|
545
|
+
.optional(),
|
|
546
|
+
recoveries: z.number().int().nonnegative().optional(),
|
|
547
|
+
artifacts: z.strictObject({
|
|
548
|
+
count: z.number().int().nonnegative(),
|
|
549
|
+
bytes: z.number().int().nonnegative().safe(),
|
|
550
|
+
}),
|
|
551
|
+
sandbox: z
|
|
552
|
+
.strictObject({
|
|
553
|
+
commands: z.number().int().nonnegative(),
|
|
554
|
+
seconds: z.number().nonnegative(),
|
|
555
|
+
})
|
|
556
|
+
.optional(),
|
|
557
|
+
progress: z.number().int().positive().safe().optional(),
|
|
558
|
+
stalledResumes: z
|
|
559
|
+
.strictObject({
|
|
560
|
+
count: z.number().int().nonnegative(),
|
|
561
|
+
sequence: z.number().int().positive(),
|
|
562
|
+
})
|
|
563
|
+
.optional(),
|
|
564
|
+
granted: z.lazy(() => runLimitsSchema).optional(),
|
|
565
|
+
inherited: z
|
|
566
|
+
.strictObject({
|
|
567
|
+
tokens: z.number().int().nonnegative().safe(),
|
|
568
|
+
estimatedCost: z.number().nonnegative().optional(),
|
|
569
|
+
artifacts: z.strictObject({
|
|
570
|
+
count: z.number().int().nonnegative(),
|
|
571
|
+
bytes: z.number().int().nonnegative().safe(),
|
|
572
|
+
}),
|
|
573
|
+
})
|
|
574
|
+
.optional(),
|
|
575
|
+
blocked: z
|
|
576
|
+
.strictObject({
|
|
577
|
+
cause: z.enum(["limit", "error"]),
|
|
578
|
+
code: z.string().min(1),
|
|
579
|
+
message: z.string(),
|
|
580
|
+
used: z.number().nonnegative().optional(),
|
|
581
|
+
value: z.number().nonnegative().optional(),
|
|
582
|
+
retryable: z.boolean().optional(),
|
|
583
|
+
details: jsonObjectSchema.optional(),
|
|
584
|
+
stepId: z.string().optional(),
|
|
585
|
+
at: z.iso.datetime({ offset: true }),
|
|
586
|
+
})
|
|
587
|
+
.optional(),
|
|
588
|
+
});
|
|
490
589
|
const validateSiblingStepIds = (steps, context, path) => {
|
|
491
590
|
const seen = new Set();
|
|
492
591
|
steps.forEach((step, index) => {
|
|
@@ -547,6 +646,13 @@ const validateStepPolicies = (steps, context, path) => {
|
|
|
547
646
|
if (step.type === "loop") {
|
|
548
647
|
validateStepPolicies(step.steps, context, [...path, index, "steps"]);
|
|
549
648
|
}
|
|
649
|
+
if (step.policies?.onFailure !== undefined) {
|
|
650
|
+
context.addIssue({
|
|
651
|
+
code: "custom",
|
|
652
|
+
message: `policies.onFailure applies to the whole run; set it in the manifest's policies, not on step ${step.id}.`,
|
|
653
|
+
path: [...path, index, "policies", "onFailure"],
|
|
654
|
+
});
|
|
655
|
+
}
|
|
550
656
|
if (step.type === "prompt" || !step.policies)
|
|
551
657
|
return;
|
|
552
658
|
for (const field of PROMPT_ONLY_POLICY_FIELDS) {
|
|
@@ -696,6 +802,7 @@ const agentManifestObjectSchema = z
|
|
|
696
802
|
maxOutputBytes: z.number().int().positive().optional(),
|
|
697
803
|
maxToolCallsPerIteration: z.number().int().positive().optional(),
|
|
698
804
|
providerTimeoutMs: z.number().int().positive().optional(),
|
|
805
|
+
...runLimitsShape,
|
|
699
806
|
})
|
|
700
807
|
.strict()
|
|
701
808
|
.optional(),
|
|
@@ -794,6 +901,9 @@ export const agentRunManifestSchema = z.strictObject({
|
|
|
794
901
|
messages: z.lazy(() => conversationMessagesInputSchema).optional(),
|
|
795
902
|
messagesSignature: z.lazy(() => messagesSignatureSchema).optional(),
|
|
796
903
|
});
|
|
904
|
+
/** Checkpoint contract versions this release reads; it writes the latest. */
|
|
905
|
+
export const RUN_CHECKPOINT_CONTRACT_VERSIONS = ["1.0", "1.1"];
|
|
906
|
+
export const RUN_CHECKPOINT_CONTRACT_VERSION = "1.1";
|
|
797
907
|
export const artifactRefSchema = z.strictObject({
|
|
798
908
|
id: z.string().min(1),
|
|
799
909
|
name: z.string().min(1),
|
|
@@ -1077,6 +1187,38 @@ export const runCheckpointSchema = z.strictObject({
|
|
|
1077
1187
|
continuation: jsonObjectSchema.optional(),
|
|
1078
1188
|
budget: runBudgetStateSchema.optional(),
|
|
1079
1189
|
messages: z.lazy(() => runMessagesStateSchema).optional(),
|
|
1190
|
+
ledger: runLedgerSchema.optional(),
|
|
1191
|
+
workspaces: z
|
|
1192
|
+
.record(z.string().min(1), z.strictObject({
|
|
1193
|
+
token: z.string().min(1).optional(),
|
|
1194
|
+
stepPath: z.string().min(1).optional(),
|
|
1195
|
+
sequence: z.number().int().positive().safe().optional(),
|
|
1196
|
+
pending: z
|
|
1197
|
+
.array(z.strictObject({
|
|
1198
|
+
path: z.string().min(1),
|
|
1199
|
+
action: z.enum(["created", "modified", "deleted"]),
|
|
1200
|
+
size: z.number().int().nonnegative().optional(),
|
|
1201
|
+
sha256: z.string().optional(),
|
|
1202
|
+
}))
|
|
1203
|
+
.optional(),
|
|
1204
|
+
}))
|
|
1205
|
+
.optional(),
|
|
1206
|
+
inputs: z
|
|
1207
|
+
.record(z.string().min(1), z.strictObject({ token: z.string().min(1) }))
|
|
1208
|
+
.optional(),
|
|
1209
|
+
fingerprints: z
|
|
1210
|
+
.strictObject({
|
|
1211
|
+
global: z.string().min(1),
|
|
1212
|
+
steps: z.array(z.string().min(1)),
|
|
1213
|
+
})
|
|
1214
|
+
.optional(),
|
|
1215
|
+
boundary: z
|
|
1216
|
+
.strictObject({
|
|
1217
|
+
stepPath: z.string().min(1),
|
|
1218
|
+
stepIndex: z.number().int().nonnegative(),
|
|
1219
|
+
executionKey: z.string().min(1).optional(),
|
|
1220
|
+
})
|
|
1221
|
+
.optional(),
|
|
1080
1222
|
createdAt: z.iso.datetime({ offset: true }),
|
|
1081
1223
|
metadata: jsonObjectSchema.optional(),
|
|
1082
1224
|
});
|
package/package.json
CHANGED