@theokit/sdk 4.49.0 → 4.51.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 +17 -0
- package/dist/{agent-JA4ILE5O.cjs → agent-B2WU3JP6.cjs} +10 -9
- package/dist/{agent-JA4ILE5O.cjs.map → agent-B2WU3JP6.cjs.map} +1 -1
- package/dist/{agent-GKX5FE5K.js → agent-DI2QQHSJ.js} +9 -8
- package/dist/{agent-GKX5FE5K.js.map → agent-DI2QQHSJ.js.map} +1 -1
- package/dist/{chunk-3NLOQEJR.js → chunk-34XOCZJO.js} +5 -16
- package/dist/chunk-34XOCZJO.js.map +1 -0
- package/dist/{chunk-64TJCXY5.cjs → chunk-3G6ZDZ6L.cjs} +5 -5
- package/dist/{chunk-64TJCXY5.cjs.map → chunk-3G6ZDZ6L.cjs.map} +1 -1
- package/dist/{chunk-JO76RWCA.cjs → chunk-72HEBGWN.cjs} +4 -4
- package/dist/{chunk-JO76RWCA.cjs.map → chunk-72HEBGWN.cjs.map} +1 -1
- package/dist/{chunk-XARLSCKA.js → chunk-ACHVCIDQ.js} +11 -11
- package/dist/chunk-ACHVCIDQ.js.map +1 -0
- package/dist/{chunk-RJBHWM6D.js → chunk-E54KDYOE.js} +3 -3
- package/dist/{chunk-RJBHWM6D.js.map → chunk-E54KDYOE.js.map} +1 -1
- package/dist/{chunk-2S6B5B2A.js → chunk-E7WDXT4X.js} +3 -3
- package/dist/{chunk-2S6B5B2A.js.map → chunk-E7WDXT4X.js.map} +1 -1
- package/dist/{chunk-TSK4VVBW.cjs → chunk-F7OBYH2X.cjs} +52 -52
- package/dist/chunk-F7OBYH2X.cjs.map +1 -0
- package/dist/{chunk-6FSQ3CHQ.js → chunk-JGYYNDAZ.js} +5 -6
- package/dist/chunk-JGYYNDAZ.js.map +1 -0
- package/dist/{chunk-UU7MAO2D.cjs → chunk-OKLYRPKL.cjs} +4 -16
- package/dist/chunk-OKLYRPKL.cjs.map +1 -0
- package/dist/{chunk-EON4YTR6.js → chunk-R2A3WIJY.js} +3 -3
- package/dist/{chunk-EON4YTR6.js.map → chunk-R2A3WIJY.js.map} +1 -1
- package/dist/chunk-RIAM53CP.js +22 -0
- package/dist/chunk-RIAM53CP.js.map +1 -0
- package/dist/{chunk-GH52NOCL.cjs → chunk-RWMNTFHZ.cjs} +9 -9
- package/dist/{chunk-GH52NOCL.cjs.map → chunk-RWMNTFHZ.cjs.map} +1 -1
- package/dist/{chunk-MZQHVN7C.js → chunk-SEZJGV7C.js} +3 -3
- package/dist/{chunk-MZQHVN7C.js.map → chunk-SEZJGV7C.js.map} +1 -1
- package/dist/{chunk-FAUKVJCC.cjs → chunk-UQHIEUDY.cjs} +3 -3
- package/dist/{chunk-FAUKVJCC.cjs.map → chunk-UQHIEUDY.cjs.map} +1 -1
- package/dist/{chunk-UJ7HK7BX.js → chunk-VK7SIDYI.js} +3 -3
- package/dist/{chunk-UJ7HK7BX.js.map → chunk-VK7SIDYI.js.map} +1 -1
- package/dist/chunk-VKJ7V7EB.cjs +25 -0
- package/dist/chunk-VKJ7V7EB.cjs.map +1 -0
- package/dist/{chunk-74VVGK7P.cjs → chunk-WUUSAMFC.cjs} +5 -5
- package/dist/{chunk-74VVGK7P.cjs.map → chunk-WUUSAMFC.cjs.map} +1 -1
- package/dist/{chunk-XA3TSBAH.cjs → chunk-XABN5HY6.cjs} +4 -5
- package/dist/chunk-XABN5HY6.cjs.map +1 -0
- package/dist/{compact-session-UUCBTBCZ.cjs → compact-session-FKYCJRAK.cjs} +4 -3
- package/dist/{compact-session-UUCBTBCZ.cjs.map → compact-session-FKYCJRAK.cjs.map} +1 -1
- package/dist/{compact-session-GF2CBKXB.js → compact-session-LF4YOT5S.js} +4 -3
- package/dist/{compact-session-GF2CBKXB.js.map → compact-session-LF4YOT5S.js.map} +1 -1
- package/dist/context/index.cjs +6 -5
- package/dist/context/index.cjs.map +1 -1
- package/dist/context/index.js +3 -2
- package/dist/context/index.js.map +1 -1
- package/dist/cron.cjs +9 -8
- package/dist/cron.js +8 -7
- package/dist/eval.cjs +8 -7
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +7 -6
- package/dist/eval.js.map +1 -1
- package/dist/filesystem/index.cjs +6 -5
- package/dist/filesystem/index.cjs.map +1 -1
- package/dist/filesystem/index.js +2 -1
- package/dist/filesystem/index.js.map +1 -1
- package/dist/{index-manager-YFFEPISE.cjs → index-manager-34ELCOAP.cjs} +6 -5
- package/dist/{index-manager-YFFEPISE.cjs.map → index-manager-34ELCOAP.cjs.map} +1 -1
- package/dist/index-manager-OMJVYS2U.js +12 -0
- package/dist/{index-manager-X5IPG2JL.js.map → index-manager-OMJVYS2U.js.map} +1 -1
- package/dist/index.cjs +183 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +320 -1
- package/dist/index.d.ts +320 -1
- package/dist/index.js +152 -13
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-I3HK3AHB.cjs → inject-session-J7Y6XACY.cjs} +4 -4
- package/dist/{inject-session-I3HK3AHB.cjs.map → inject-session-J7Y6XACY.cjs.map} +1 -1
- package/dist/{inject-session-NR64GB3T.js → inject-session-MWRJENH4.js} +3 -3
- package/dist/{inject-session-NR64GB3T.js.map → inject-session-MWRJENH4.js.map} +1 -1
- package/dist/internal/memory/adapters/index.cjs +2 -1
- package/dist/internal/memory/adapters/index.js +2 -1
- package/dist/internal/security/index.cjs +9 -8
- package/dist/internal/security/index.js +2 -1
- package/dist/path-safety.cjs +9 -8
- package/dist/path-safety.js +2 -1
- package/dist/skills.cjs +5 -4
- package/dist/skills.js +3 -2
- package/dist/workflow.cjs +11 -10
- package/dist/workflow.js +3 -2
- package/package.json +1 -1
- package/dist/chunk-3NLOQEJR.js.map +0 -1
- package/dist/chunk-6FSQ3CHQ.js.map +0 -1
- package/dist/chunk-TSK4VVBW.cjs.map +0 -1
- package/dist/chunk-UU7MAO2D.cjs.map +0 -1
- package/dist/chunk-XA3TSBAH.cjs.map +0 -1
- package/dist/chunk-XARLSCKA.js.map +0 -1
- package/dist/index-manager-X5IPG2JL.js +0 -11
package/dist/index.d.ts
CHANGED
|
@@ -806,6 +806,122 @@ declare class AgentFactory {
|
|
|
806
806
|
static create(common: Partial<AgentOptions>): AgentFactory;
|
|
807
807
|
}
|
|
808
808
|
|
|
809
|
+
/**
|
|
810
|
+
* Decide whether a tool call proceeds, and say WHY — as a typed signal rather than a tool result.
|
|
811
|
+
*
|
|
812
|
+
* When a veto is delivered as an ordinary tool result, the MODEL reads it as output: it sees a
|
|
813
|
+
* string, concludes the tool failed for some reason, and retries or works around it. A denial, an
|
|
814
|
+
* error, and a tool that legitimately returned the word "denied" become indistinguishable to
|
|
815
|
+
* everything downstream — including the surface that should be telling the user what happened.
|
|
816
|
+
*
|
|
817
|
+
* ## What is generic, and what is not
|
|
818
|
+
*
|
|
819
|
+
* The RULE is a precedence: an explicit per-tool decision outranks the mode, a convenience mode does
|
|
820
|
+
* not overturn an explicit refusal, and anything undecided falls to the mode. The VOCABULARY is not
|
|
821
|
+
* — which tools exist belongs to the product and arrives as data. Nothing here names one.
|
|
822
|
+
*
|
|
823
|
+
* Deliberately separate from the blast-radius policy: that one answers "what does this action
|
|
824
|
+
* reach", this one answers "who said yes". Keeping them apart is what lets a product gate on reach
|
|
825
|
+
* without re-implementing the mode ladder, and compose both where it needs to.
|
|
826
|
+
*
|
|
827
|
+
* @public
|
|
828
|
+
*/
|
|
829
|
+
/** What the operator chose for everything not decided per tool. @public */
|
|
830
|
+
type ApprovalMode = "ask" | "never-ask" | "refuse-all";
|
|
831
|
+
/** @public */
|
|
832
|
+
type ApprovalOutcome = "allow" | "ask" | "deny";
|
|
833
|
+
/** @public */
|
|
834
|
+
type ApprovalReason = "explicitly-allowed" | "explicitly-denied" | "mode-ask" | "mode-never-ask" | "mode-refuse-all";
|
|
835
|
+
/** @public */
|
|
836
|
+
interface ApprovalInput {
|
|
837
|
+
readonly tool: string;
|
|
838
|
+
readonly mode: ApprovalMode;
|
|
839
|
+
/** Tools the operator allowed once and for all. */
|
|
840
|
+
readonly allowed?: readonly string[];
|
|
841
|
+
/** Tools the operator refused. Outranks `allowed` and every mode. */
|
|
842
|
+
readonly denied?: readonly string[];
|
|
843
|
+
}
|
|
844
|
+
/** @public */
|
|
845
|
+
interface ApprovalDecision {
|
|
846
|
+
readonly outcome: ApprovalOutcome;
|
|
847
|
+
readonly reason: ApprovalReason;
|
|
848
|
+
/** The tool the decision was about, so a surface names it without re-deriving it. */
|
|
849
|
+
readonly tool: string;
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* @returns the outcome, why it was reached, and the tool it was about.
|
|
853
|
+
* @public
|
|
854
|
+
*/
|
|
855
|
+
declare function decideApproval(input: ApprovalInput): ApprovalDecision;
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* Decide an action by what it REACHES and whether it can be undone — not by its name.
|
|
859
|
+
*
|
|
860
|
+
* A sandbox answers "which files may this process touch", and that is a different question from the
|
|
861
|
+
* one that decides whether an action is safe. A tool that drops a production database touches no
|
|
862
|
+
* file the sandbox cares about; a tool that lists pods reaches an entire cluster while writing
|
|
863
|
+
* nothing. Confinement covers the disk, not the reach.
|
|
864
|
+
*
|
|
865
|
+
* With nothing better available, every product gates on the tool's NAME: an allowlist of strings
|
|
866
|
+
* that says nothing about what the tool does, drifts the moment one is renamed, and cannot be
|
|
867
|
+
* reasoned about by anyone who did not write it. A guard each product re-implements is a guard some
|
|
868
|
+
* product forgets.
|
|
869
|
+
*
|
|
870
|
+
* ## What is generic here, and what is not
|
|
871
|
+
*
|
|
872
|
+
* The RULE is: an action declares the scope it reaches and whether it is reversible, and a policy
|
|
873
|
+
* decides from those two facts plus what the operator granted. The VOCABULARY is not — which scopes
|
|
874
|
+
* exist ("cluster:prod", "billing-account", "the laptop") belongs to the product and arrives as
|
|
875
|
+
* data. Nothing in this module names a scope, the same way the security floor names no sandbox mode
|
|
876
|
+
* and the trust posture names no capability.
|
|
877
|
+
*
|
|
878
|
+
* ## Why the reason is part of the answer
|
|
879
|
+
*
|
|
880
|
+
* "The sandbox stopped this" and "you never granted reach to that scope" are different facts with
|
|
881
|
+
* different fixes, and an operator told the wrong one widens the wrong thing. So a decision carries
|
|
882
|
+
* WHY — the same reason a trust posture reports its `source` and a wiring record distinguishes
|
|
883
|
+
* withheld-by-trust from never-configured.
|
|
884
|
+
*
|
|
885
|
+
* @public
|
|
886
|
+
*/
|
|
887
|
+
/** What an action reaches, and whether it can be taken back. @public */
|
|
888
|
+
interface DeclaredAction {
|
|
889
|
+
/**
|
|
890
|
+
* The product's name for what this action reaches. An empty string is treated as UNDECLARED and
|
|
891
|
+
* refused: a tool that forgot to declare is not a tool that reaches nothing.
|
|
892
|
+
*/
|
|
893
|
+
readonly scope: string;
|
|
894
|
+
/**
|
|
895
|
+
* Whether the action can be undone. Reversible actions inside a granted scope proceed;
|
|
896
|
+
* irreversible ones ask, because granting reach is not granting destruction.
|
|
897
|
+
*/
|
|
898
|
+
readonly reversible: boolean;
|
|
899
|
+
}
|
|
900
|
+
/** @public */
|
|
901
|
+
interface BlastRadiusInput {
|
|
902
|
+
readonly action: DeclaredAction;
|
|
903
|
+
/** Scopes the operator granted reach to. Empty grants nothing — never everything. */
|
|
904
|
+
readonly granted: readonly string[];
|
|
905
|
+
/** Scopes where the operator pre-approved irreversible actions, so an unattended run can work. */
|
|
906
|
+
readonly irreversibleAllowed?: readonly string[];
|
|
907
|
+
}
|
|
908
|
+
/** @public */
|
|
909
|
+
type BlastRadiusOutcome = "allow" | "require-approval" | "refuse";
|
|
910
|
+
/** Why the decision came out that way. Rendered to the operator and read by an audit. @public */
|
|
911
|
+
type BlastRadiusReason = "within-granted-scope" | "irreversible" | "scope-not-granted" | "scope-undeclared";
|
|
912
|
+
/** @public */
|
|
913
|
+
interface BlastRadiusDecision {
|
|
914
|
+
readonly outcome: BlastRadiusOutcome;
|
|
915
|
+
readonly reason: BlastRadiusReason;
|
|
916
|
+
/** The scope the decision was made about, so a surface can name it without re-deriving it. */
|
|
917
|
+
readonly scope: string;
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* @returns the outcome with the reason and the scope it was decided on.
|
|
921
|
+
* @public
|
|
922
|
+
*/
|
|
923
|
+
declare function evaluateBlastRadius(input: BlastRadiusInput): BlastRadiusDecision;
|
|
924
|
+
|
|
809
925
|
/**
|
|
810
926
|
* computeCost — apply pricing entries to a TokenUsage and produce a
|
|
811
927
|
* CostBreakdown (ADRs D377, D378).
|
|
@@ -1067,6 +1183,48 @@ declare class UnicodeNormalizer {
|
|
|
1067
1183
|
static create(opts?: UnicodeNormalizerOptions): Processor;
|
|
1068
1184
|
}
|
|
1069
1185
|
|
|
1186
|
+
/**
|
|
1187
|
+
* Report whether a credential resolved — never what it is.
|
|
1188
|
+
*
|
|
1189
|
+
* Every agent product grows a "why can't I use this model?" surface: a doctor command, a status
|
|
1190
|
+
* panel, a startup diagnostic. Each needs to know whether a credential resolved, and each is one
|
|
1191
|
+
* careless line from printing it. The line is careless precisely because it is convenient — the
|
|
1192
|
+
* value is right there, and whoever is debugging a routing problem wants to see it.
|
|
1193
|
+
*
|
|
1194
|
+
* So presence-only is the DEFAULT here rather than each consumer's discipline. Discipline is what
|
|
1195
|
+
* every product has until the day it does not, and a leaked key is not a defect anyone can withdraw.
|
|
1196
|
+
*
|
|
1197
|
+
* ## Why a fingerprint and not a prefix
|
|
1198
|
+
*
|
|
1199
|
+
* A report has to be actionable: two people asking "is it the same key?" need something to compare.
|
|
1200
|
+
* The convenient answer — the first eight characters — is still the secret, and it is enough to
|
|
1201
|
+
* identify a key in a breach corpus. A hash is not.
|
|
1202
|
+
*
|
|
1203
|
+
* @public
|
|
1204
|
+
*/
|
|
1205
|
+
/** @public */
|
|
1206
|
+
interface CredentialInput {
|
|
1207
|
+
/** The product's name for the provider. This module never knows one of its own. */
|
|
1208
|
+
readonly provider: string;
|
|
1209
|
+
/** The resolved secret, or `undefined`/empty when nothing resolved. */
|
|
1210
|
+
readonly value: string | undefined;
|
|
1211
|
+
/** Where it came from, in the product's vocabulary — `env`, `file`, `keychain`, `oauth`. */
|
|
1212
|
+
readonly source: string;
|
|
1213
|
+
}
|
|
1214
|
+
/** @public */
|
|
1215
|
+
interface CredentialReport {
|
|
1216
|
+
readonly provider: string;
|
|
1217
|
+
readonly present: boolean;
|
|
1218
|
+
readonly source: string;
|
|
1219
|
+
/** Eight hex characters of a hash. Absent when no credential resolved. Never a prefix. */
|
|
1220
|
+
readonly fingerprint?: string;
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* @returns a report safe to log, render and attach to a support bundle.
|
|
1224
|
+
* @public
|
|
1225
|
+
*/
|
|
1226
|
+
declare function describeCredential(input: CredentialInput): CredentialReport;
|
|
1227
|
+
|
|
1070
1228
|
/**
|
|
1071
1229
|
* Plugin contract — RUNTIME value + type re-exports (T1.1, ADRs D97-D101).
|
|
1072
1230
|
*
|
|
@@ -2019,6 +2177,87 @@ type MutableEnv = Record<string, string | undefined>;
|
|
|
2019
2177
|
*/
|
|
2020
2178
|
declare function loadProjectEnv(env?: MutableEnv, load?: (() => void) | undefined): void;
|
|
2021
2179
|
|
|
2180
|
+
/**
|
|
2181
|
+
* Decide which session artifacts may be deleted — and never delete them.
|
|
2182
|
+
*
|
|
2183
|
+
* This package creates session artifacts (transcripts, locks, temp files) and cleans up only what is
|
|
2184
|
+
* in flight in the operation doing the cleaning: a lock it just released, a `.tmp` from a failed
|
|
2185
|
+
* atomic write. Nothing collects the rest, so every consumer either writes its own collector or lets
|
|
2186
|
+
* the directory grow without bound — and a hand-rolled collector on the path that deletes a user's
|
|
2187
|
+
* transcript is the worst place for each product to learn the same lessons separately.
|
|
2188
|
+
*
|
|
2189
|
+
* ## Planning is not deleting, deliberately
|
|
2190
|
+
*
|
|
2191
|
+
* A function that decided AND deleted could not be tested without a filesystem, and the case that
|
|
2192
|
+
* matters most — "we could not establish whether this session is live" — would have to be simulated
|
|
2193
|
+
* rather than asserted. Here the decision is pure: the plan IS the dry run, and executing it is a
|
|
2194
|
+
* separate act on a value someone can read first. That separation is the dry-run guarantee, rather
|
|
2195
|
+
* than a flag that has to be remembered.
|
|
2196
|
+
*
|
|
2197
|
+
* ## The tri-state
|
|
2198
|
+
*
|
|
2199
|
+
* `keep`, `reap`, `undetermined`. An artifact whose liveness could not be established is never
|
|
2200
|
+
* reaped and never quietly counted as dead. Collapsing "could not determine" into "not there" is how
|
|
2201
|
+
* a collector deletes a session running on another machine, or behind a mount that answered slowly.
|
|
2202
|
+
* The third bucket costs a branch and buys the only guarantee worth having on this path.
|
|
2203
|
+
*
|
|
2204
|
+
* @public
|
|
2205
|
+
*/
|
|
2206
|
+
|
|
2207
|
+
/** Raised when a retention policy cannot be honoured as written. @public */
|
|
2208
|
+
declare class RetentionPolicyError extends TheokitAgentError {
|
|
2209
|
+
readonly name = "RetentionPolicyError";
|
|
2210
|
+
}
|
|
2211
|
+
/** @public */
|
|
2212
|
+
interface ReapableArtifact {
|
|
2213
|
+
readonly id: string;
|
|
2214
|
+
/** Epoch milliseconds. Compared against an injected `nowMs`, never against a read clock. */
|
|
2215
|
+
readonly lastModifiedMs: number;
|
|
2216
|
+
/**
|
|
2217
|
+
* Whether a writer still holds this artifact. `"unknown"` when the caller could not establish it —
|
|
2218
|
+
* a stale lock behind a slow mount, a PID on another host — and it is honoured as a third answer
|
|
2219
|
+
* rather than folded into `false`.
|
|
2220
|
+
*/
|
|
2221
|
+
readonly live: boolean | "unknown";
|
|
2222
|
+
}
|
|
2223
|
+
/** @public */
|
|
2224
|
+
interface RetentionPolicy {
|
|
2225
|
+
/** Artifacts strictly older than this are candidates. The boundary itself is kept. */
|
|
2226
|
+
readonly maxAgeMs: number;
|
|
2227
|
+
/**
|
|
2228
|
+
* A FLOOR on how many artifacts survive: "you will always have your last N sessions". When
|
|
2229
|
+
* liveness and the retention window already spare N or more, this changes nothing; when they
|
|
2230
|
+
* spare fewer, the newest of the remainder are spared until the count reaches N.
|
|
2231
|
+
*
|
|
2232
|
+
* Undetermined artifacts do NOT count toward the floor. Their liveness was never established, so
|
|
2233
|
+
* counting them would let a transient mount failure satisfy the floor with artifacts nobody
|
|
2234
|
+
* confirmed exist as sessions — and quietly delete the ones that do.
|
|
2235
|
+
*/
|
|
2236
|
+
readonly keepLast: number;
|
|
2237
|
+
}
|
|
2238
|
+
/** Why an artifact survived. @public */
|
|
2239
|
+
type KeepReason = "live" | "within-retention" | "keep-last";
|
|
2240
|
+
/** @public */
|
|
2241
|
+
interface KeptArtifact extends ReapableArtifact {
|
|
2242
|
+
readonly reason: KeepReason;
|
|
2243
|
+
}
|
|
2244
|
+
/** @public */
|
|
2245
|
+
interface ReapPlan {
|
|
2246
|
+
/** Safe to delete. Everything here was decided, not defaulted. */
|
|
2247
|
+
readonly reap: readonly ReapableArtifact[];
|
|
2248
|
+
readonly keep: readonly KeptArtifact[];
|
|
2249
|
+
/** Liveness could not be established. Never deleted, never counted as kept. */
|
|
2250
|
+
readonly undetermined: readonly ReapableArtifact[];
|
|
2251
|
+
}
|
|
2252
|
+
/** @public */
|
|
2253
|
+
interface ReapPlanInput {
|
|
2254
|
+
readonly artifacts: readonly ReapableArtifact[];
|
|
2255
|
+
readonly retention: RetentionPolicy;
|
|
2256
|
+
/** Injected so the plan is reproducible and testable; this module never reads a clock. */
|
|
2257
|
+
readonly nowMs: number;
|
|
2258
|
+
}
|
|
2259
|
+
declare function planReaping(input: ReapPlanInput): ReapPlan;
|
|
2260
|
+
|
|
2022
2261
|
/** The internal JSON-Schema shape the synthetic `output` tool consumes. */
|
|
2023
2262
|
type NormalizedJsonSchema = Record<string, unknown>;
|
|
2024
2263
|
/**
|
|
@@ -2154,6 +2393,51 @@ interface SecurityFloorInput {
|
|
|
2154
2393
|
*/
|
|
2155
2394
|
declare function applySecurityFloor(input: SecurityFloorInput): string | undefined;
|
|
2156
2395
|
|
|
2396
|
+
/**
|
|
2397
|
+
* Refuse to destroy a session another process is still writing.
|
|
2398
|
+
*
|
|
2399
|
+
* Every agent product that lets a user delete or overwrite a session needs this, and the failure is
|
|
2400
|
+
* unrecoverable in the worst way: a transcript removed underneath a running session takes with it
|
|
2401
|
+
* everything that session had not flushed, and nothing errors. The user sees a successful delete.
|
|
2402
|
+
*
|
|
2403
|
+
* ## The ordering is the point
|
|
2404
|
+
*
|
|
2405
|
+
* The check runs BEFORE anything is mutated. Removing a registry entry and then refusing leaves a
|
|
2406
|
+
* session that can be neither opened nor deleted — worse than either outcome on its own. So this is
|
|
2407
|
+
* a function the caller passes through rather than a flag it may consult afterwards: the throw is
|
|
2408
|
+
* what stops the mutation, and there is no way to read the answer and forget to act on it.
|
|
2409
|
+
*
|
|
2410
|
+
* ## What is generic, and what is not
|
|
2411
|
+
*
|
|
2412
|
+
* The RULE is: a session declared live is not destroyable, and refusing says which one and why. The
|
|
2413
|
+
* VOCABULARY is not — how a product decides liveness (a pointer file, the newest transcript, a
|
|
2414
|
+
* lease, an active registry entry) is its own. Nothing here touches a filesystem.
|
|
2415
|
+
*
|
|
2416
|
+
* @public
|
|
2417
|
+
*/
|
|
2418
|
+
|
|
2419
|
+
/** Why the destruction was refused. @public */
|
|
2420
|
+
type LiveSessionReason = "session-is-live" | "liveness-undetermined";
|
|
2421
|
+
/** @public */
|
|
2422
|
+
declare class LiveSessionError extends TheokitAgentError {
|
|
2423
|
+
readonly name = "LiveSessionError";
|
|
2424
|
+
readonly sessionId: string;
|
|
2425
|
+
readonly reason: LiveSessionReason;
|
|
2426
|
+
constructor(sessionId: string, reason: LiveSessionReason);
|
|
2427
|
+
}
|
|
2428
|
+
/**
|
|
2429
|
+
* Throw unless `sessionId` is safe to destroy.
|
|
2430
|
+
*
|
|
2431
|
+
* @param live - the sessions the product declares live, or `undefined` when it could not tell.
|
|
2432
|
+
* The distinction is load-bearing: an EMPTY set is a legitimate answer (nothing is open), while
|
|
2433
|
+
* `undefined` refuses. A product that swallowed a read error and returned `[]` would hand this
|
|
2434
|
+
* guard the one input that disables it entirely, on exactly the path that destroys data.
|
|
2435
|
+
* @throws LiveSessionError naming the session and the reason — "close that session" and "the guard
|
|
2436
|
+
* could not read" have different fixes, and conflating them sends the user to close nothing.
|
|
2437
|
+
* @public
|
|
2438
|
+
*/
|
|
2439
|
+
declare function guardSessionDestruction(sessionId: string, live: readonly string[] | undefined): void;
|
|
2440
|
+
|
|
2157
2441
|
/**
|
|
2158
2442
|
* M3 #62 — scoped session state.
|
|
2159
2443
|
*
|
|
@@ -2642,6 +2926,41 @@ declare class Theokit {
|
|
|
2642
2926
|
};
|
|
2643
2927
|
}
|
|
2644
2928
|
|
|
2929
|
+
/**
|
|
2930
|
+
* Attach a blast-radius declaration to a tool, so the approval layer gates on what the tool DOES.
|
|
2931
|
+
*
|
|
2932
|
+
* Without this the only key available to a policy is the tool's NAME, which says nothing about the
|
|
2933
|
+
* action, drifts the moment a tool is renamed, and cannot be reviewed by anyone who did not write
|
|
2934
|
+
* it. `delete_namespace` and `list_pods` differ by a word.
|
|
2935
|
+
*
|
|
2936
|
+
* ## Why a wrapper rather than a field on the input schema
|
|
2937
|
+
*
|
|
2938
|
+
* `inputSchema` is what the MODEL sees. Blast radius is not for the model — it is for the approval
|
|
2939
|
+
* layer — and putting it there would leak policy into the prompt and let a model-authored argument
|
|
2940
|
+
* influence its own gate. The declaration rides alongside the tool instead, under a symbol so it
|
|
2941
|
+
* cannot collide with a tool's own properties or be serialised into a prompt by accident.
|
|
2942
|
+
*
|
|
2943
|
+
* @public
|
|
2944
|
+
*/
|
|
2945
|
+
|
|
2946
|
+
/** @public */
|
|
2947
|
+
type WithBlastRadius<T> = T & {
|
|
2948
|
+
readonly [DECLARED]?: DeclaredAction;
|
|
2949
|
+
};
|
|
2950
|
+
/**
|
|
2951
|
+
* @returns the same tool, with its action declared. The tool is not otherwise altered — the model
|
|
2952
|
+
* must see exactly what it saw before.
|
|
2953
|
+
* @public
|
|
2954
|
+
*/
|
|
2955
|
+
declare function withBlastRadius<T extends object>(tool: T, action: DeclaredAction): WithBlastRadius<T>;
|
|
2956
|
+
/**
|
|
2957
|
+
* @returns the declared action, or `undefined` when the tool never declared one — NOT an empty
|
|
2958
|
+
* action. "Never declared" and "declared as reaching nothing" are different facts, and collapsing
|
|
2959
|
+
* them is how an unreviewed tool passes as harmless.
|
|
2960
|
+
* @public
|
|
2961
|
+
*/
|
|
2962
|
+
declare function describeAction(tool: object): DeclaredAction | undefined;
|
|
2963
|
+
|
|
2645
2964
|
/**
|
|
2646
2965
|
* SE7 — `ToolError`: thrown FROM a tool `handler` to report a failure back to
|
|
2647
2966
|
* the model with structured content (text and/or an image), not just a string.
|
|
@@ -2892,4 +3211,4 @@ interface WiringRecordInput<K extends string> {
|
|
|
2892
3211
|
*/
|
|
2893
3212
|
declare function recordWiring<K extends string>(input: WiringRecordInput<K>): Readonly<Record<K, WiredEntity>>;
|
|
2894
3213
|
|
|
2895
|
-
export { Agent, AgentBuilder, AgentDefinition, AgentDescription, AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, type CounterBudgetTrackerOptions, CustomTool, type DeclaredLayer, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DiagnosticsSink, type DreamingSweepOptions, type DreamingSweepResult, type EnvOptOut, type EnvReachabilityAudit, type EnvReachabilityInput, ErrorMetadata, EventBus, type EvictReason, GOAL_CONTINUATION_MARKER, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, GoalEvent, type GoalLoopAgent, GoalOptions, GoalResult, InlineSkill, JobQueue, type JobQueueOptions, JudgeCredentialError, JudgeResult, LayerOrderError, type LayerValues, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, PermissionEngine, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, PermissionMode, PermissionPlugin, type PermissionPluginOptions, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, Run, RunEventSink, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, SOVEREIGN_ENV_KEYS, Security, type SecurityFloorInput, type SessionMessage, type SessionMessagePart, type SessionScope, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, type SovereignEnvKey, Squad, type SquadOptions, type SquadRun, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, type TrustLevel, type TrustPosture, type TrustPostureInput, type TrustSource, UngatedCapabilityError, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, type WiredEntity, type WiringRecordInput, applySecurityFloor, auditEnvReachability, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, estimateTokens, extractRawId, foldLayers, getPricingEntry, inferApiMode, isValidTaskId, loadProjectEnv, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, recordWiring, resolveTrustPosture, runGoalLoop, scopedConversationId, sessionScopePrefix, setDiagnosticsSink, toShareGptTrajectory, verifyLayerOrdering, withCwdMutex };
|
|
3214
|
+
export { Agent, AgentBuilder, AgentDefinition, AgentDescription, AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type ApprovalDecision, type ApprovalInput, type ApprovalMode, type ApprovalOutcome, type ApprovalReason, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, type BlastRadiusDecision, type BlastRadiusInput, type BlastRadiusOutcome, type BlastRadiusReason, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, type CounterBudgetTrackerOptions, type CredentialInput, type CredentialReport, CustomTool, type DeclaredAction, type DeclaredLayer, type DeepPartial, type DefineProviderOptions, type DefineToolSpec, type DiagnosticsSink, type DreamingSweepOptions, type DreamingSweepResult, type EnvOptOut, type EnvReachabilityAudit, type EnvReachabilityInput, ErrorMetadata, EventBus, type EvictReason, GOAL_CONTINUATION_MARKER, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, GoalEvent, type GoalLoopAgent, GoalOptions, GoalResult, InlineSkill, JobQueue, type JobQueueOptions, JudgeCredentialError, JudgeResult, type KeepReason, type KeptArtifact, LayerOrderError, type LayerValues, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LiveSessionError, type LiveSessionReason, LocalOptions, McpServerConfig, Memory, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, NoopMemoryProvider, type NormalizedJsonSchema, PermissionEngine, type PermissionGate, type PermissionGateContext, type PermissionGateDecision, PermissionMode, PermissionPlugin, type PermissionPluginOptions, Plugin, PluginsSettings, PreToolCallDecision, Processor, Provider, ProviderProfile, ProviderRoutingSettings, type ReapPlan, type ReapPlanInput, type ReapableArtifact, type RetentionPolicy, RetentionPolicyError, Run, RunEventSink, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, SOVEREIGN_ENV_KEYS, Security, type SecurityFloorInput, type SessionMessage, type SessionMessagePart, type SessionScope, type ShareGptMessage, type ShareGptTrajectory, SkillReadTool, SkillsSettings, type SovereignEnvKey, Squad, type SquadOptions, type SquadRun, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, TokenLimiter, type TokenLimiterOptions, Tool, ToolError, ToolResultContentBlock, type TrustLevel, type TrustPosture, type TrustPostureInput, type TrustSource, UngatedCapabilityError, UnicodeNormalizer, type UnicodeNormalizerOptions, UsageAccumulator, type WiredEntity, type WiringRecordInput, type WithBlastRadius, applySecurityFloor, auditEnvReachability, chargeAndCheckThresholds, computeCost, createCounterBudgetTracker, decideApproval, describeAction, describeCredential, estimateTokens, evaluateBlastRadius, extractRawId, foldLayers, getPricingEntry, guardSessionDestruction, inferApiMode, isValidTaskId, loadProjectEnv, migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, planReaping, preflightCheck, recordWiring, resolveTrustPosture, runGoalLoop, scopedConversationId, sessionScopePrefix, setDiagnosticsSink, toShareGptTrajectory, verifyLayerOrdering, withBlastRadius, withCwdMutex };
|
package/dist/index.js
CHANGED
|
@@ -3,13 +3,13 @@ export { JudgeCredentialError } from './chunk-PAV4ZPSW.js';
|
|
|
3
3
|
export { StreamObjectError } from './chunk-3KY7MHR4.js';
|
|
4
4
|
export { GenerateObjectError } from './chunk-35NFZ7QB.js';
|
|
5
5
|
import './chunk-O3IZ7JEL.js';
|
|
6
|
-
import { Workflow, agentStep } from './chunk-
|
|
6
|
+
import { Workflow, agentStep } from './chunk-R2A3WIJY.js';
|
|
7
7
|
import './chunk-HK4HRLWE.js';
|
|
8
8
|
import './chunk-CAH3G4IS.js';
|
|
9
|
-
export { Cron } from './chunk-
|
|
10
|
-
import { MEMORY_EMBEDDING_ADAPTERS, resolveApiKey, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-
|
|
11
|
-
export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry } from './chunk-
|
|
12
|
-
import './chunk-
|
|
9
|
+
export { Cron } from './chunk-SEZJGV7C.js';
|
|
10
|
+
import { MEMORY_EMBEDDING_ADAPTERS, resolveApiKey, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-ACHVCIDQ.js';
|
|
11
|
+
export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry } from './chunk-ACHVCIDQ.js';
|
|
12
|
+
import './chunk-VK7SIDYI.js';
|
|
13
13
|
import './chunk-2SFBB54R.js';
|
|
14
14
|
import { configure, submit, list, get, cancel, subscribe } from './chunk-GNMPCZNN.js';
|
|
15
15
|
export { emitRunEvent } from './chunk-GNMPCZNN.js';
|
|
@@ -19,10 +19,10 @@ import { discoverProviderPlugins, shouldUseFixtureMode, isFixtureApiKey, httpReq
|
|
|
19
19
|
import './chunk-4QEC4CCS.js';
|
|
20
20
|
import './chunk-F4RUADRC.js';
|
|
21
21
|
import './chunk-ZTEAJAE6.js';
|
|
22
|
-
import { lanceStoragePath, LanceIndex, readFactsFromMarkdown, defaultIndexPath, openMemoryDb, memoryDir } from './chunk-
|
|
22
|
+
import { lanceStoragePath, LanceIndex, readFactsFromMarkdown, defaultIndexPath, openMemoryDb, memoryDir } from './chunk-E54KDYOE.js';
|
|
23
23
|
import './chunk-J5RW43IR.js';
|
|
24
24
|
import './chunk-AM2CNBKE.js';
|
|
25
|
-
import './chunk-
|
|
25
|
+
import './chunk-34XOCZJO.js';
|
|
26
26
|
import './chunk-ZS6SLELQ.js';
|
|
27
27
|
import './chunk-LLE7HPRI.js';
|
|
28
28
|
import './chunk-SNKY3C2L.js';
|
|
@@ -50,15 +50,16 @@ import { parseModelId } from './chunk-X2FR4OIT.js';
|
|
|
50
50
|
import { registerBuiltins, listProviders, getCatalogCapabilities, getProviderProfile } from './chunk-Z6N6SDNR.js';
|
|
51
51
|
import './chunk-L4JFQCG4.js';
|
|
52
52
|
import './chunk-5NBUH3NO.js';
|
|
53
|
-
import './chunk-
|
|
54
|
-
import './chunk-
|
|
53
|
+
import './chunk-E7WDXT4X.js';
|
|
54
|
+
import './chunk-JGYYNDAZ.js';
|
|
55
|
+
import './chunk-RIAM53CP.js';
|
|
55
56
|
import './chunk-OLLOUAUJ.js';
|
|
56
57
|
import { BudgetExceededError, TheokitAgentError, MemoryAdapterError, AuthenticationError, ConfigurationError } from './chunk-MRKSSN36.js';
|
|
57
58
|
export { AgentDisposedError, AgentRunError, AuthenticationError, BudgetExceededError, ConfigurationError, IntegrationNotConnectedError, InvalidTaskIdError, MemoryAdapterError, NetworkError, RateLimitError, TaskNotFoundError, TheokitAgentError, UnknownAgentError, UnsupportedBudgetOperationError, UnsupportedRunOperationError, UnsupportedTaskOperationError, isTransientError } from './chunk-MRKSSN36.js';
|
|
58
59
|
import { diag, redactSecrets, addPattern } from './chunk-PBML2FHN.js';
|
|
59
60
|
export { setDiagnosticsSink } from './chunk-PBML2FHN.js';
|
|
61
|
+
import { createHash, randomUUID } from 'crypto';
|
|
60
62
|
import { z } from 'zod';
|
|
61
|
-
import { randomUUID, createHash } from 'crypto';
|
|
62
63
|
import { mkdir, readFile } from 'fs/promises';
|
|
63
64
|
import { join } from 'path';
|
|
64
65
|
import { existsSync, rmSync, mkdirSync, renameSync } from 'fs';
|
|
@@ -106,6 +107,39 @@ var AgentFactory = class {
|
|
|
106
107
|
}
|
|
107
108
|
};
|
|
108
109
|
|
|
110
|
+
// src/approval-policy.ts
|
|
111
|
+
var BY_MODE = {
|
|
112
|
+
ask: { outcome: "ask", reason: "mode-ask" },
|
|
113
|
+
"never-ask": { outcome: "allow", reason: "mode-never-ask" },
|
|
114
|
+
"refuse-all": { outcome: "deny", reason: "mode-refuse-all" }
|
|
115
|
+
};
|
|
116
|
+
function decideApproval(input) {
|
|
117
|
+
const { tool } = input;
|
|
118
|
+
if ((input.denied ?? []).includes(tool)) {
|
|
119
|
+
return { outcome: "deny", reason: "explicitly-denied", tool };
|
|
120
|
+
}
|
|
121
|
+
if ((input.allowed ?? []).includes(tool)) {
|
|
122
|
+
return { outcome: "allow", reason: "explicitly-allowed", tool };
|
|
123
|
+
}
|
|
124
|
+
const fromMode = BY_MODE[input.mode];
|
|
125
|
+
return { outcome: fromMode.outcome, reason: fromMode.reason, tool };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// src/blast-radius.ts
|
|
129
|
+
function evaluateBlastRadius(input) {
|
|
130
|
+
const { scope, reversible } = input.action;
|
|
131
|
+
if (scope.length === 0) {
|
|
132
|
+
return { outcome: "refuse", reason: "scope-undeclared", scope };
|
|
133
|
+
}
|
|
134
|
+
if (!input.granted.includes(scope)) {
|
|
135
|
+
return { outcome: "refuse", reason: "scope-not-granted", scope };
|
|
136
|
+
}
|
|
137
|
+
if (!reversible && !(input.irreversibleAllowed ?? []).includes(scope)) {
|
|
138
|
+
return { outcome: "require-approval", reason: "irreversible", scope };
|
|
139
|
+
}
|
|
140
|
+
return { outcome: "allow", reason: "within-granted-scope", scope };
|
|
141
|
+
}
|
|
142
|
+
|
|
109
143
|
// src/internal/budget/calendar-window.ts
|
|
110
144
|
function startOfDayUtc(now = /* @__PURE__ */ new Date()) {
|
|
111
145
|
return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()));
|
|
@@ -571,6 +605,18 @@ var Skill = class {
|
|
|
571
605
|
return createSkill(spec);
|
|
572
606
|
}
|
|
573
607
|
};
|
|
608
|
+
function describeCredential(input) {
|
|
609
|
+
const secret = (input.value ?? "").trim();
|
|
610
|
+
if (secret.length === 0) {
|
|
611
|
+
return { provider: input.provider, present: false, source: input.source };
|
|
612
|
+
}
|
|
613
|
+
return {
|
|
614
|
+
provider: input.provider,
|
|
615
|
+
present: true,
|
|
616
|
+
source: input.source,
|
|
617
|
+
fingerprint: createHash("sha256").update(secret).digest("hex").slice(0, 8)
|
|
618
|
+
};
|
|
619
|
+
}
|
|
574
620
|
|
|
575
621
|
// src/define-provider.ts
|
|
576
622
|
function defineProvider(profile, opts) {
|
|
@@ -1217,7 +1263,7 @@ var Memory = {
|
|
|
1217
1263
|
openArgs.embedding = await resolveEmbedding(opts.embedding, peer.MEMORY_EMBEDDING_ADAPTERS);
|
|
1218
1264
|
return await peer.IndexManager.open(openArgs);
|
|
1219
1265
|
}
|
|
1220
|
-
const { IndexManager } = await import('./index-manager-
|
|
1266
|
+
const { IndexManager } = await import('./index-manager-OMJVYS2U.js');
|
|
1221
1267
|
openArgs.embedding = await resolveEmbedding(opts.embedding, MEMORY_EMBEDDING_ADAPTERS);
|
|
1222
1268
|
return await IndexManager.open(openArgs);
|
|
1223
1269
|
},
|
|
@@ -1574,6 +1620,60 @@ function loadProjectEnv(env = process.env, load = typeof process.loadEnvFile ===
|
|
|
1574
1620
|
}
|
|
1575
1621
|
}
|
|
1576
1622
|
|
|
1623
|
+
// src/reap-plan.ts
|
|
1624
|
+
var RetentionPolicyError = class extends TheokitAgentError {
|
|
1625
|
+
name = "RetentionPolicyError";
|
|
1626
|
+
};
|
|
1627
|
+
function assertPolicy(retention) {
|
|
1628
|
+
const { maxAgeMs, keepLast } = retention;
|
|
1629
|
+
if (!Number.isFinite(maxAgeMs) || maxAgeMs < 0) {
|
|
1630
|
+
throw new RetentionPolicyError(
|
|
1631
|
+
`retention.maxAgeMs must be a non-negative number of milliseconds, got ${String(maxAgeMs)}`
|
|
1632
|
+
);
|
|
1633
|
+
}
|
|
1634
|
+
if (!Number.isInteger(keepLast) || keepLast < 0) {
|
|
1635
|
+
throw new RetentionPolicyError(
|
|
1636
|
+
`retention.keepLast must be a non-negative integer, got ${String(keepLast)}`
|
|
1637
|
+
);
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
function classifyByOwnReason(input) {
|
|
1641
|
+
const keep = [];
|
|
1642
|
+
const atRisk = [];
|
|
1643
|
+
for (const artifact of input.artifacts) {
|
|
1644
|
+
if (artifact.live === "unknown") continue;
|
|
1645
|
+
if (artifact.live === true) {
|
|
1646
|
+
keep.push({ ...artifact, reason: "live" });
|
|
1647
|
+
continue;
|
|
1648
|
+
}
|
|
1649
|
+
if (input.nowMs - artifact.lastModifiedMs <= input.retention.maxAgeMs) {
|
|
1650
|
+
keep.push({ ...artifact, reason: "within-retention" });
|
|
1651
|
+
continue;
|
|
1652
|
+
}
|
|
1653
|
+
atRisk.push(artifact);
|
|
1654
|
+
}
|
|
1655
|
+
return { keep, atRisk };
|
|
1656
|
+
}
|
|
1657
|
+
function applyFloor(kept, atRisk, keepLast) {
|
|
1658
|
+
const shortfall = Math.max(0, keepLast - kept.length);
|
|
1659
|
+
const newestFirst = [...atRisk].sort((a, b) => b.lastModifiedMs - a.lastModifiedMs);
|
|
1660
|
+
const spared = new Set(newestFirst.slice(0, shortfall).map((a) => a.id));
|
|
1661
|
+
const rescued = [];
|
|
1662
|
+
const reap = [];
|
|
1663
|
+
for (const artifact of atRisk) {
|
|
1664
|
+
if (spared.has(artifact.id)) rescued.push({ ...artifact, reason: "keep-last" });
|
|
1665
|
+
else reap.push(artifact);
|
|
1666
|
+
}
|
|
1667
|
+
return { rescued, reap };
|
|
1668
|
+
}
|
|
1669
|
+
function planReaping(input) {
|
|
1670
|
+
assertPolicy(input.retention);
|
|
1671
|
+
const undetermined = input.artifacts.filter((a) => a.live === "unknown");
|
|
1672
|
+
const { keep, atRisk } = classifyByOwnReason(input);
|
|
1673
|
+
const { rescued, reap } = applyFloor(keep, atRisk, input.retention.keepLast);
|
|
1674
|
+
return { reap, keep: [...keep, ...rescued], undetermined };
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1577
1677
|
// src/schema-normalizer.ts
|
|
1578
1678
|
function isJsonSchemaObject(s) {
|
|
1579
1679
|
if (typeof s !== "object" || s === null) return false;
|
|
@@ -1704,6 +1804,28 @@ function applySecurityFloor(input) {
|
|
|
1704
1804
|
return input.layers[input.override] ?? tightenOnly(input, baseline(input));
|
|
1705
1805
|
}
|
|
1706
1806
|
|
|
1807
|
+
// src/session-guard.ts
|
|
1808
|
+
var LiveSessionError = class extends TheokitAgentError {
|
|
1809
|
+
name = "LiveSessionError";
|
|
1810
|
+
sessionId;
|
|
1811
|
+
reason;
|
|
1812
|
+
constructor(sessionId, reason) {
|
|
1813
|
+
super(
|
|
1814
|
+
reason === "session-is-live" ? `refusing to destroy session ${sessionId}: it is live \u2014 another process is probably still appending to it. Switch to another session first.` : `refusing to destroy session ${sessionId}: the set of live sessions could not be determined, so this cannot be shown to be safe. Resolve that before deleting.`
|
|
1815
|
+
);
|
|
1816
|
+
this.sessionId = sessionId;
|
|
1817
|
+
this.reason = reason;
|
|
1818
|
+
}
|
|
1819
|
+
};
|
|
1820
|
+
function guardSessionDestruction(sessionId, live) {
|
|
1821
|
+
if (live === void 0) {
|
|
1822
|
+
throw new LiveSessionError(sessionId, "liveness-undetermined");
|
|
1823
|
+
}
|
|
1824
|
+
if (live.includes(sessionId)) {
|
|
1825
|
+
throw new LiveSessionError(sessionId, "session-is-live");
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1707
1829
|
// src/session-scope.ts
|
|
1708
1830
|
function scopedConversationId(scope, id) {
|
|
1709
1831
|
return `${scope}__${id}`;
|
|
@@ -1717,7 +1839,7 @@ function isBuiltAgent(m) {
|
|
|
1717
1839
|
return typeof m.send === "function";
|
|
1718
1840
|
}
|
|
1719
1841
|
async function materialize(def, index) {
|
|
1720
|
-
const { Agent: Agent2 } = await import('./agent-
|
|
1842
|
+
const { Agent: Agent2 } = await import('./agent-DI2QQHSJ.js');
|
|
1721
1843
|
return Agent2.create({
|
|
1722
1844
|
// `AgentDefinition.model` admits the sentinel `'inherit'`, which is not a model id. Inheriting
|
|
1723
1845
|
// here means "declare nothing and let the default apply" — forwarding the literal would create
|
|
@@ -2107,6 +2229,23 @@ async function executeCatalogRequest(request) {
|
|
|
2107
2229
|
return httpRequest(request.path, { apiKey });
|
|
2108
2230
|
}
|
|
2109
2231
|
|
|
2232
|
+
// src/tool-blast-radius.ts
|
|
2233
|
+
var DECLARED = /* @__PURE__ */ Symbol.for("@theokit/sdk.blastRadius");
|
|
2234
|
+
function withBlastRadius(tool, action) {
|
|
2235
|
+
return Object.defineProperty(tool, DECLARED, {
|
|
2236
|
+
value: action,
|
|
2237
|
+
// `enumerable: false` is defensive and NOT load-bearing — checked, not assumed. Flipping it to
|
|
2238
|
+
// true leaves every case green, because the symbol key already excludes this from `Object.keys`
|
|
2239
|
+
// and `JSON.stringify`. It stays because a future string-keyed variant would need it, and the
|
|
2240
|
+
// next reader should not have to discover that the flag has no test behind it.
|
|
2241
|
+
enumerable: false,
|
|
2242
|
+
configurable: true
|
|
2243
|
+
});
|
|
2244
|
+
}
|
|
2245
|
+
function describeAction(tool) {
|
|
2246
|
+
return tool[DECLARED];
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2110
2249
|
// src/trajectory-helpers.ts
|
|
2111
2250
|
function toShareGptTrajectory(result, options) {
|
|
2112
2251
|
if (!result.ok) return null;
|
|
@@ -2234,6 +2373,6 @@ function recordWiring(input) {
|
|
|
2234
2373
|
return record;
|
|
2235
2374
|
}
|
|
2236
2375
|
|
|
2237
|
-
export { AgentFactory, Budget, EventBus, JobQueue, LayerOrderError, Memory, NoopMemoryProvider, PermissionEngine, PermissionPlugin, Plugin, Provider, SOVEREIGN_ENV_KEYS, Security, Skill, SkillReadTool, Squad, Task, Theokit, TokenLimiter, UngatedCapabilityError, UnicodeNormalizer, applyMode, applySecurityFloor, auditEnvReachability, chargeAndCheckThresholds, createCounterBudgetTracker, estimateTokens, extractRawId, foldLayers, inferApiMode, loadProjectEnv, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, preflightCheck, recordWiring, resolveTrustPosture, runGoalLoop, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, verifyLayerOrdering };
|
|
2376
|
+
export { AgentFactory, Budget, EventBus, JobQueue, LayerOrderError, LiveSessionError, Memory, NoopMemoryProvider, PermissionEngine, PermissionPlugin, Plugin, Provider, RetentionPolicyError, SOVEREIGN_ENV_KEYS, Security, Skill, SkillReadTool, Squad, Task, Theokit, TokenLimiter, UngatedCapabilityError, UnicodeNormalizer, applyMode, applySecurityFloor, auditEnvReachability, chargeAndCheckThresholds, createCounterBudgetTracker, decideApproval, describeAction, describeCredential, estimateTokens, evaluateBlastRadius, extractRawId, foldLayers, guardSessionDestruction, inferApiMode, loadProjectEnv, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeSchema, normalizeUsage, planReaping, preflightCheck, recordWiring, resolveTrustPosture, runGoalLoop, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, verifyLayerOrdering, withBlastRadius };
|
|
2238
2377
|
//# sourceMappingURL=index.js.map
|
|
2239
2378
|
//# sourceMappingURL=index.js.map
|