@theokit/sdk 2.28.0 → 2.29.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 +24 -0
- package/dist/a2a/index.cjs +373 -17
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +373 -17
- package/dist/a2a/index.js.map +1 -1
- package/dist/{cron-BR1NCSk1.d.cts → cron-COSAehOL.d.ts} +110 -3
- package/dist/{cron-DgEQCJ2i.d.ts → cron-yJoNUZxe.d.cts} +110 -3
- package/dist/cron.cjs +914 -508
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +915 -509
- package/dist/cron.js.map +1 -1
- package/dist/{errors-CbY3pxY7.d.ts → errors-BxMIlgLP.d.ts} +1 -1
- package/dist/{errors-DLMNb4Ka.d.cts → errors-tP-8O-hR.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +914 -508
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +915 -509
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +973 -570
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +972 -568
- package/dist/index.js.map +1 -1
- package/dist/internal/persistence/conversation-storage-fs.d.cts +4 -0
- package/dist/internal/persistence/conversation-storage-fs.d.ts +4 -0
- package/dist/internal/persistence/conversation-storage-memory.d.cts +4 -0
- package/dist/internal/persistence/conversation-storage-memory.d.ts +4 -0
- package/dist/internal/persistence/objective-coerce.d.cts +9 -0
- package/dist/internal/persistence/objective-coerce.d.ts +9 -0
- package/dist/internal/runtime/lifecycle/wrap-completion-check-run.d.ts +30 -0
- package/dist/internal/runtime/local-agent/local-agent-goal-extensions.d.ts +80 -0
- package/dist/internal/runtime/objective/objective-store.d.ts +33 -0
- package/dist/{run-CdWiihyU.d.cts → run-q_P0vHlY.d.cts} +71 -2
- package/dist/{run-CdWiihyU.d.ts → run-q_P0vHlY.d.ts} +71 -2
- package/dist/types/agent.d.ts +32 -1
- package/dist/types/conversation-storage.d.ts +23 -0
- package/dist/types/goal-events.d.ts +7 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/objective.d.ts +45 -0
- package/dist/types/run-events.d.ts +12 -1
- package/dist/types/run.d.ts +58 -0
- package/package.json +3 -3
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
19
|
import type { ConversationStorageAdapter, SessionMeta, SessionMetaPatch, StoredMessage } from "../../types/conversation-storage.js";
|
|
20
|
+
import type { ObjectiveRecord } from "../../types/objective.js";
|
|
20
21
|
export interface FileSystemConversationStorageOptions {
|
|
21
22
|
/** Root directory under which `.theokit/agents/<id>/` lives. Defaults to `process.cwd()`. */
|
|
22
23
|
root?: string;
|
|
@@ -41,5 +42,8 @@ export declare class FileSystemConversationStorage implements ConversationStorag
|
|
|
41
42
|
compact(conversationId: string, maxTurns: number): Promise<void>;
|
|
42
43
|
getSessionMeta(conversationId: string): Promise<SessionMeta | undefined>;
|
|
43
44
|
setSessionMeta(conversationId: string, patch: SessionMetaPatch): Promise<void>;
|
|
45
|
+
getObjectiveRecord(conversationId: string): Promise<ObjectiveRecord | undefined>;
|
|
46
|
+
setObjectiveRecord(conversationId: string, record: ObjectiveRecord | null): Promise<void>;
|
|
47
|
+
updateObjectiveRecord(conversationId: string, mutate: (current: ObjectiveRecord | undefined) => ObjectiveRecord | null | undefined): Promise<void>;
|
|
44
48
|
dispose(): Promise<void>;
|
|
45
49
|
}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
19
|
import type { ConversationStorageAdapter, SessionMeta, SessionMetaPatch, StoredMessage } from "../../types/conversation-storage.js";
|
|
20
|
+
import type { ObjectiveRecord } from "../../types/objective.js";
|
|
20
21
|
export interface FileSystemConversationStorageOptions {
|
|
21
22
|
/** Root directory under which `.theokit/agents/<id>/` lives. Defaults to `process.cwd()`. */
|
|
22
23
|
root?: string;
|
|
@@ -41,5 +42,8 @@ export declare class FileSystemConversationStorage implements ConversationStorag
|
|
|
41
42
|
compact(conversationId: string, maxTurns: number): Promise<void>;
|
|
42
43
|
getSessionMeta(conversationId: string): Promise<SessionMeta | undefined>;
|
|
43
44
|
setSessionMeta(conversationId: string, patch: SessionMetaPatch): Promise<void>;
|
|
45
|
+
getObjectiveRecord(conversationId: string): Promise<ObjectiveRecord | undefined>;
|
|
46
|
+
setObjectiveRecord(conversationId: string, record: ObjectiveRecord | null): Promise<void>;
|
|
47
|
+
updateObjectiveRecord(conversationId: string, mutate: (current: ObjectiveRecord | undefined) => ObjectiveRecord | null | undefined): Promise<void>;
|
|
44
48
|
dispose(): Promise<void>;
|
|
45
49
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
14
|
import type { ConversationStorageAdapter, SessionMeta, SessionMetaPatch, StoredMessage } from "../../types/conversation-storage.js";
|
|
15
|
+
import type { ObjectiveRecord } from "../../types/objective.js";
|
|
15
16
|
export declare class InMemoryConversationStorage implements ConversationStorageAdapter {
|
|
16
17
|
#private;
|
|
17
18
|
getMessages(conversationId: string, opts?: {
|
|
@@ -28,5 +29,8 @@ export declare class InMemoryConversationStorage implements ConversationStorageA
|
|
|
28
29
|
}): Promise<readonly string[]>;
|
|
29
30
|
getSessionMeta(conversationId: string): Promise<SessionMeta | undefined>;
|
|
30
31
|
setSessionMeta(conversationId: string, patch: SessionMetaPatch): Promise<void>;
|
|
32
|
+
getObjectiveRecord(conversationId: string): Promise<ObjectiveRecord | undefined>;
|
|
33
|
+
setObjectiveRecord(conversationId: string, record: ObjectiveRecord | null): Promise<void>;
|
|
34
|
+
updateObjectiveRecord(conversationId: string, mutate: (current: ObjectiveRecord | undefined) => ObjectiveRecord | null | undefined): Promise<void>;
|
|
31
35
|
dispose(): Promise<void>;
|
|
32
36
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
14
|
import type { ConversationStorageAdapter, SessionMeta, SessionMetaPatch, StoredMessage } from "../../types/conversation-storage.js";
|
|
15
|
+
import type { ObjectiveRecord } from "../../types/objective.js";
|
|
15
16
|
export declare class InMemoryConversationStorage implements ConversationStorageAdapter {
|
|
16
17
|
#private;
|
|
17
18
|
getMessages(conversationId: string, opts?: {
|
|
@@ -28,5 +29,8 @@ export declare class InMemoryConversationStorage implements ConversationStorageA
|
|
|
28
29
|
}): Promise<readonly string[]>;
|
|
29
30
|
getSessionMeta(conversationId: string): Promise<SessionMeta | undefined>;
|
|
30
31
|
setSessionMeta(conversationId: string, patch: SessionMetaPatch): Promise<void>;
|
|
32
|
+
getObjectiveRecord(conversationId: string): Promise<ObjectiveRecord | undefined>;
|
|
33
|
+
setObjectiveRecord(conversationId: string, record: ObjectiveRecord | null): Promise<void>;
|
|
34
|
+
updateObjectiveRecord(conversationId: string, mutate: (current: ObjectiveRecord | undefined) => ObjectiveRecord | null | undefined): Promise<void>;
|
|
31
35
|
dispose(): Promise<void>;
|
|
32
36
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SE33 (ADR 0012) — coerce an untrusted parsed JSON value into an
|
|
3
|
+
* {@link ObjectiveRecord}, or `undefined` when the shape is not a valid record.
|
|
4
|
+
* Malformed JSON is caught upstream (the reader distinguishes ENOENT); this
|
|
5
|
+
* guards against a structurally-wrong but valid-JSON file.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function coerceObjectiveRecord(raw: unknown): ObjectiveRecord | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SE33 (ADR 0012) — coerce an untrusted parsed JSON value into an
|
|
3
|
+
* {@link ObjectiveRecord}, or `undefined` when the shape is not a valid record.
|
|
4
|
+
* Malformed JSON is caught upstream (the reader distinguishes ENOENT); this
|
|
5
|
+
* guards against a structurally-wrong but valid-JSON file.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function coerceObjectiveRecord(raw: unknown): ObjectiveRecord | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SE34 — wrap a {@link Run} so a finished reply is scored by the shipped
|
|
3
|
+
* LLM-as-judge against {@link SendOptions.completionCheck} (`isTaskComplete`).
|
|
4
|
+
* The verdict is attached to `wait()`'s {@link RunResult.completionCheck} and a
|
|
5
|
+
* `completion_check` run-event is emitted. This is the finer-grained, single-
|
|
6
|
+
* `send()` completion gate (contrast `runUntil`, which judges BETWEEN sends).
|
|
7
|
+
*
|
|
8
|
+
* Non-invasive: only wraps when `completionCheck` is set, only judges a
|
|
9
|
+
* `finished` run with text, memoizes so the judge runs EXACTLY ONCE, and a
|
|
10
|
+
* Proxy preserves every other Run member. A fail-safe: a judge parse failure
|
|
11
|
+
* yields `complete: false` (never silently "done"). The judge model is injected
|
|
12
|
+
* via `deps.judge` so this module stays free of the Agent façade import.
|
|
13
|
+
*
|
|
14
|
+
* The judge fires from `wait()` (not from `stream()`); a stream-only consumer
|
|
15
|
+
* must call `wait()` to trigger the verdict + the `completion_check` event.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
import { type RunEventSink } from "../../../types/run-events.js";
|
|
20
|
+
import type { JudgeContext, JudgeOptions } from "../../judge/judge-call.js";
|
|
21
|
+
import type { JudgeResult } from "../../judge/types.js";
|
|
22
|
+
export interface CompletionCheckDeps {
|
|
23
|
+
judge: (ctx: JudgeContext, opts?: JudgeOptions) => Promise<JudgeResult>;
|
|
24
|
+
}
|
|
25
|
+
export declare function wrapRunWithCompletionCheck(args: {
|
|
26
|
+
run: Run;
|
|
27
|
+
completionCheck: CompletionCheck | undefined;
|
|
28
|
+
onRunEvent: RunEventSink | undefined;
|
|
29
|
+
deps: CompletionCheckDeps;
|
|
30
|
+
}): Run;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SE33 (ADR 0012) — the durable-objective agent methods, extracted from
|
|
3
|
+
* `local-agent.ts` (G8 budget) mirroring `local-agent-runtime-extensions.ts`.
|
|
4
|
+
* Each resolves the agent's storage handle to a `ConversationStorageAdapter` and
|
|
5
|
+
* delegates to the pure `objective-store`. All no-op when the run is not
|
|
6
|
+
* memory-backed (an adapter that omits the optional objective methods).
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
import type { ConversationStorageAdapter } from "../../../types/conversation-storage.js";
|
|
11
|
+
import type { GoalOptions, GoalResult } from "../../../types/goal-events.js";
|
|
12
|
+
import type { AgentGoalConfig, DurableGoalOptions, ObjectiveRecord } from "../../../types/objective.js";
|
|
13
|
+
export declare function localAgentSetObjective(handle: ConversationStorageAdapter | string, objective: string, opts: {
|
|
14
|
+
threadId: string;
|
|
15
|
+
} & DurableGoalOptions): Promise<void>;
|
|
16
|
+
export declare function localAgentGetObjective(handle: ConversationStorageAdapter | string, opts: {
|
|
17
|
+
threadId: string;
|
|
18
|
+
}): Promise<ObjectiveRecord | undefined>;
|
|
19
|
+
export declare function localAgentUpdateObjectiveOptions(handle: ConversationStorageAdapter | string, opts: {
|
|
20
|
+
threadId: string;
|
|
21
|
+
} & DurableGoalOptions): Promise<void>;
|
|
22
|
+
export declare function localAgentClearObjective(handle: ConversationStorageAdapter | string, opts: {
|
|
23
|
+
threadId: string;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* SE34 — resolve the ACTIVE durable objective text for a thread, for the
|
|
27
|
+
* `<current-objective>` context projection. Returns `undefined` when no
|
|
28
|
+
* objective is set, the run is not memory-backed, or the objective is no longer
|
|
29
|
+
* active (`done`/`paused` ⇒ nothing to project this turn).
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveCurrentObjectiveText(handle: ConversationStorageAdapter | string, threadId: string): Promise<string | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* SE34 — format the `<current-objective>` context signal, prepended to the
|
|
34
|
+
* assembled system prompt (or standalone when there is none). Pure — the string
|
|
35
|
+
* shape is locked here so the projection is testable without a live send.
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatObjectiveProjection(objective: string, assembled: string | undefined): string;
|
|
38
|
+
/**
|
|
39
|
+
* Outcome of resolving a `runUntil()` call with NO explicit goal against the
|
|
40
|
+
* durable thread-scoped objective (ADR D3/D4):
|
|
41
|
+
* - `run` — an objective is set AND a judge resolves; carries the effective run.
|
|
42
|
+
* - `inert` — an objective is set but NO explicit judge resolves; the standing
|
|
43
|
+
* objective is inert (no scoring, no budget consumed) — the judge is
|
|
44
|
+
* the activation switch (ADR D3, mirroring Mastra).
|
|
45
|
+
* - `exhausted` — an objective is set + activated but its durable budget
|
|
46
|
+
* (`maxRuns`) is spent; the loop is NOT entered (a 0-turn run would
|
|
47
|
+
* burn a judge call for nothing). Raising `maxRuns` later resumes it.
|
|
48
|
+
* - `none` — no objective set for the thread.
|
|
49
|
+
*/
|
|
50
|
+
export type DurableRunResolution = {
|
|
51
|
+
kind: "run";
|
|
52
|
+
goal: string;
|
|
53
|
+
options: GoalOptions;
|
|
54
|
+
} | {
|
|
55
|
+
kind: "inert";
|
|
56
|
+
} | {
|
|
57
|
+
kind: "exhausted";
|
|
58
|
+
} | {
|
|
59
|
+
kind: "none";
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Resolve a `runUntil()` call with NO explicit goal against the durable
|
|
63
|
+
* thread-scoped objective (ADR D4).
|
|
64
|
+
*
|
|
65
|
+
* Precedence (ADR D3): per-call option → per-objective option → standing agent
|
|
66
|
+
* `goal` config → built-in default. The per-call `maxTurns` (if any) is capped
|
|
67
|
+
* by the durable budget remaining (`maxRuns - runsUsed`), so the objective can
|
|
68
|
+
* never overrun its total run budget across resumes. Activation requires an
|
|
69
|
+
* EXPLICIT judge (per-objective `judgeModel` or standing `goal.judgeModel`); the
|
|
70
|
+
* built-in default judge does NOT auto-activate a standing objective.
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveDurableRun(handle: ConversationStorageAdapter | string, goalConfig: AgentGoalConfig | undefined, threadId: string, callerOptions: GoalOptions | undefined): Promise<DurableRunResolution>;
|
|
73
|
+
/**
|
|
74
|
+
* Write a completed `runUntil()` pass back into the durable objective (ADR D4):
|
|
75
|
+
* accumulate `runsUsed`, and map the loop result to a durable status —
|
|
76
|
+
* `completed → done`, `paused → paused`, `failed (budget exhausted) → active`
|
|
77
|
+
* so a later `runUntil()` resumes the same objective. No-op when the objective
|
|
78
|
+
* was cleared mid-run.
|
|
79
|
+
*/
|
|
80
|
+
export declare function persistDurableProgress(handle: ConversationStorageAdapter | string, threadId: string, result: GoalResult): Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SE33 (ADR 0012) — the pure durable-objective store over a
|
|
3
|
+
* `ConversationStorageAdapter`. Set / get / update-options / clear / write-back
|
|
4
|
+
* progress for a thread-scoped {@link ObjectiveRecord}. Every operation is a
|
|
5
|
+
* no-op (typed degradation, never throws) when the adapter omits the optional
|
|
6
|
+
* `getObjectiveRecord` / `setObjectiveRecord` methods — the same contract SE4's
|
|
7
|
+
* session manager uses.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
import type { DurableGoalOptions, ObjectiveRecord, ObjectiveStatus } from "../../../types/objective.js";
|
|
12
|
+
/** Read the durable objective for `conversationId`, or `undefined` (unset / unsupported). */
|
|
13
|
+
export declare function getObjective(adapter: ConversationStorageAdapter, conversationId: string): Promise<ObjectiveRecord | undefined>;
|
|
14
|
+
/** Set a FRESH objective (status `active`, `runsUsed` 0). Overwrites any prior record. */
|
|
15
|
+
export declare function setObjective(adapter: ConversationStorageAdapter, conversationId: string, objective: string, options?: DurableGoalOptions): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Merge `patch` into the active objective's `options` (only provided fields
|
|
18
|
+
* change). No-op when no objective is set. Keeps `objective` / `status` /
|
|
19
|
+
* `runsUsed` unchanged. Atomic read-modify-write via {@link mutateObjective}.
|
|
20
|
+
*/
|
|
21
|
+
export declare function updateObjectiveOptions(adapter: ConversationStorageAdapter, conversationId: string, patch: DurableGoalOptions): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Write back loop progress (`runsUsed` + `status`) after a `runUntil` pass. No-op
|
|
24
|
+
* when unset. Atomic read-modify-write via {@link mutateObjective} — the read that
|
|
25
|
+
* feeds the increment happens under the adapter's lock, so concurrent write-backs
|
|
26
|
+
* on one thread cannot drop turns (HIGH-1).
|
|
27
|
+
*/
|
|
28
|
+
export declare function writeObjectiveProgress(adapter: ConversationStorageAdapter, conversationId: string, progress: {
|
|
29
|
+
runsUsed: number;
|
|
30
|
+
status: ObjectiveStatus;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
/** Clear the durable objective for `conversationId`. */
|
|
33
|
+
export declare function clearObjective(adapter: ConversationStorageAdapter, conversationId: string): Promise<void>;
|
|
@@ -87,7 +87,7 @@ interface ToolResultGuardOptions {
|
|
|
87
87
|
*
|
|
88
88
|
* @public
|
|
89
89
|
*/
|
|
90
|
-
type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunTripwireEvent;
|
|
90
|
+
type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunTripwireEvent | RunCompletionCheckEvent;
|
|
91
91
|
/**
|
|
92
92
|
* SE24 — a guardrail processor called `abort()`; the run stops with a tripwire.
|
|
93
93
|
* Delivered via {@link SendOptions.onRunEvent} (mirrors the `RunResult.tripwire`
|
|
@@ -144,6 +144,17 @@ interface RunTaskCompletedEvent {
|
|
|
144
144
|
readonly taskId: string;
|
|
145
145
|
readonly status: "completed" | "failed" | "stopped";
|
|
146
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* SE34 — the per-send completion check (`isTaskComplete`) produced a verdict.
|
|
149
|
+
* Emitted once, after a finished run's reply is judged against
|
|
150
|
+
* {@link SendOptions.completionCheck}. Distinct from `task_completed` (which is
|
|
151
|
+
* background-task/subagent lifecycle). Mirrors {@link RunResult.completionCheck}.
|
|
152
|
+
*/
|
|
153
|
+
interface RunCompletionCheckEvent {
|
|
154
|
+
readonly type: "completion_check";
|
|
155
|
+
readonly complete: boolean;
|
|
156
|
+
readonly reason: string;
|
|
157
|
+
}
|
|
147
158
|
/** The conversation crossed a compaction boundary (history was summarized). */
|
|
148
159
|
interface RunCompactBoundaryEvent {
|
|
149
160
|
readonly type: "compact_boundary";
|
|
@@ -1052,6 +1063,13 @@ interface RunResult {
|
|
|
1052
1063
|
* @public
|
|
1053
1064
|
*/
|
|
1054
1065
|
stoppedByDoomLoop?: boolean;
|
|
1066
|
+
/**
|
|
1067
|
+
* SE34 — the per-send completion verdict, populated when
|
|
1068
|
+
* {@link SendOptions.completionCheck} was set AND the run finished. Absent on
|
|
1069
|
+
* non-finished runs and when no completion check was requested. Reuses the
|
|
1070
|
+
* shipped LLM-as-judge (same one `runUntil` drives). @public
|
|
1071
|
+
*/
|
|
1072
|
+
completionCheck?: CompletionCheckResult;
|
|
1055
1073
|
}
|
|
1056
1074
|
/**
|
|
1057
1075
|
* Doom-loop guard thresholds (see {@link SendOptions.doomLoop}). Both are counts of CONSECUTIVE
|
|
@@ -1324,6 +1342,57 @@ interface SendOptions {
|
|
|
1324
1342
|
* @public
|
|
1325
1343
|
*/
|
|
1326
1344
|
maxIterations?: number;
|
|
1345
|
+
/**
|
|
1346
|
+
* SE34 — per-send completion check (`isTaskComplete`). After this single
|
|
1347
|
+
* `send()` reaches a terminal `finished` state, the shipped LLM-as-judge
|
|
1348
|
+
* scores the final reply against `criteria` and surfaces the verdict on
|
|
1349
|
+
* {@link RunResult.completionCheck} + a `completion_check` run-event. This is
|
|
1350
|
+
* the finer-grained, single-`send()` gate (contrast `runUntil`, which judges
|
|
1351
|
+
* the FULL response BETWEEN sends). Opt-in — absent ⇒ the send is byte-identical
|
|
1352
|
+
* to today (no extra judge call). Non-finished runs skip the check. The judge
|
|
1353
|
+
* runs when `wait()` is called on the returned `Run`; a stream-only consumer
|
|
1354
|
+
* must call `wait()` to trigger the verdict + the `completion_check` event.
|
|
1355
|
+
*
|
|
1356
|
+
* @public
|
|
1357
|
+
*/
|
|
1358
|
+
completionCheck?: CompletionCheck;
|
|
1359
|
+
/**
|
|
1360
|
+
* SE34 — project the standing durable objective (SE33) for this `threadId`
|
|
1361
|
+
* into the model context for this send as `<current-objective>…`, so the
|
|
1362
|
+
* model always sees what it is working toward. Opt-in — absent ⇒ the assembled
|
|
1363
|
+
* system prompt is byte-identical to today. Only an ACTIVE objective is
|
|
1364
|
+
* projected (`done`/`paused` ⇒ nothing injected). Reuses the SE33 objective
|
|
1365
|
+
* store + the system-prompt assembly seam (no general signal framework — YAGNI).
|
|
1366
|
+
*
|
|
1367
|
+
* @public
|
|
1368
|
+
*/
|
|
1369
|
+
objectiveThreadId?: string;
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* SE34 — the per-send completion criterion (see {@link SendOptions.completionCheck}).
|
|
1373
|
+
*
|
|
1374
|
+
* @public
|
|
1375
|
+
*/
|
|
1376
|
+
interface CompletionCheck {
|
|
1377
|
+
/** What "complete" means for this send — fed to the judge as the goal. */
|
|
1378
|
+
criteria: string;
|
|
1379
|
+
/** Judge model identifier. Default `"openai/gpt-4o-mini"`. */
|
|
1380
|
+
judgeModel?: string;
|
|
1381
|
+
/** Override env for the judge auxiliary agent. Default `OPENROUTER_API_KEY`. */
|
|
1382
|
+
apiKey?: string;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* SE34 — the resolved per-send completion verdict (see {@link RunResult.completionCheck}).
|
|
1386
|
+
*
|
|
1387
|
+
* @public
|
|
1388
|
+
*/
|
|
1389
|
+
interface CompletionCheckResult {
|
|
1390
|
+
/** `true` when the judge ruled the send's reply satisfies the criteria. */
|
|
1391
|
+
complete: boolean;
|
|
1392
|
+
/** The judge's stated reason. */
|
|
1393
|
+
reason: string;
|
|
1394
|
+
/** `true` when the judge output could not be parsed — fail-safe `complete: false`. */
|
|
1395
|
+
parseFailed: boolean;
|
|
1327
1396
|
}
|
|
1328
1397
|
/**
|
|
1329
1398
|
* Handle to a single prompt submission.
|
|
@@ -1397,4 +1466,4 @@ interface GenerateRunResult<O> {
|
|
|
1397
1466
|
};
|
|
1398
1467
|
}
|
|
1399
1468
|
|
|
1400
|
-
export { type
|
|
1469
|
+
export { type SDKImageDimension as $, type AgentConversationTurn as A, type RunEvent as B, type CustomTool as C, type DoomLoopThresholds as D, type RunEventSink as E, type RunGitInfo as F, type GenerateOptions as G, type RunOperation as H, type ImageBlock as I, type RunPermissionDeniedEvent as J, type RunRateLimitEvent as K, type RunStatus as L, type ModelSelection as M, type RunTaskCompletedEvent as N, type OutputProcessorContext as O, type Processor as P, type RunTaskStartedEvent as Q, type RunResult as R, type SDKMessage as S, type ToolResultContentBlock as T, type RunTaskUpdatedEvent as U, type RunToCompletionOptions as V, type RunToCompletionResult as W, type RunToolProgressEvent as X, type RunTripwireEvent as Y, type SDKAssistantMessage as Z, type SDKImage as _, type McpServerConfig as a, type SDKObjectDelta as a0, type SDKRequestMessage as a1, type SDKStatusMessage as a2, type SDKSystemMessage as a3, type SDKTaskMessage as a4, type SDKThinkingMessage as a5, type SDKToolUseMessage as a6, type SDKUserMessage as a7, type SDKUserMessageEvent as a8, type SendOptions as a9, type UserMessageAppendedUpdate as aA, emitRunEvent as aB, type ShellCommand as aa, type ShellConversationTurn as ab, type ShellOutput as ac, type ShellOutputDeltaUpdate as ad, type StepCompletedUpdate as ae, type StepStartedUpdate as af, type StreamToCompletionResult as ag, type SummaryCompletedUpdate as ah, type SummaryStartedUpdate as ai, type SummaryUpdate as aj, type TextBlock as ak, type TextDeltaUpdate as al, type ThinkingCompletedUpdate as am, type ThinkingDeltaUpdate as an, type ThinkingMessage as ao, type TokenDeltaUpdate as ap, type TokenUsage as aq, type ToolCall as ar, type ToolCallCompletedUpdate as as, type ToolCallStartedUpdate as at, type ToolContextMessage as au, type ToolResult as av, type ToolResultGuardOptions as aw, type ToolUseBlock as ax, type TurnEndedUpdate as ay, type UserMessage as az, type Run as b, type MessageOrigin as c, type AssistantMessage as d, type CompletionCheck as e, type CompletionCheckResult as f, type ConversationStep as g, type ConversationTurn as h, type CostBreakdown as i, type CostSource as j, type CostStatus as k, type GenerateRunResult as l, type InputProcessorContext as m, type InteractionUpdate as n, type McpAuthConfig as o, type McpHttpServerConfig as p, type McpOAuthConfig as q, type McpStdioServerConfig as r, type ModelParameterValue as s, type PartialToolCallUpdate as t, type ProcessorControls as u, type ProcessorTripwire as v, type ProcessorViolation as w, type RunCompactBoundaryEvent as x, type RunCompletionCheckEvent as y, type RunErrorDetail as z };
|
|
@@ -87,7 +87,7 @@ interface ToolResultGuardOptions {
|
|
|
87
87
|
*
|
|
88
88
|
* @public
|
|
89
89
|
*/
|
|
90
|
-
type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunTripwireEvent;
|
|
90
|
+
type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunTripwireEvent | RunCompletionCheckEvent;
|
|
91
91
|
/**
|
|
92
92
|
* SE24 — a guardrail processor called `abort()`; the run stops with a tripwire.
|
|
93
93
|
* Delivered via {@link SendOptions.onRunEvent} (mirrors the `RunResult.tripwire`
|
|
@@ -144,6 +144,17 @@ interface RunTaskCompletedEvent {
|
|
|
144
144
|
readonly taskId: string;
|
|
145
145
|
readonly status: "completed" | "failed" | "stopped";
|
|
146
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* SE34 — the per-send completion check (`isTaskComplete`) produced a verdict.
|
|
149
|
+
* Emitted once, after a finished run's reply is judged against
|
|
150
|
+
* {@link SendOptions.completionCheck}. Distinct from `task_completed` (which is
|
|
151
|
+
* background-task/subagent lifecycle). Mirrors {@link RunResult.completionCheck}.
|
|
152
|
+
*/
|
|
153
|
+
interface RunCompletionCheckEvent {
|
|
154
|
+
readonly type: "completion_check";
|
|
155
|
+
readonly complete: boolean;
|
|
156
|
+
readonly reason: string;
|
|
157
|
+
}
|
|
147
158
|
/** The conversation crossed a compaction boundary (history was summarized). */
|
|
148
159
|
interface RunCompactBoundaryEvent {
|
|
149
160
|
readonly type: "compact_boundary";
|
|
@@ -1052,6 +1063,13 @@ interface RunResult {
|
|
|
1052
1063
|
* @public
|
|
1053
1064
|
*/
|
|
1054
1065
|
stoppedByDoomLoop?: boolean;
|
|
1066
|
+
/**
|
|
1067
|
+
* SE34 — the per-send completion verdict, populated when
|
|
1068
|
+
* {@link SendOptions.completionCheck} was set AND the run finished. Absent on
|
|
1069
|
+
* non-finished runs and when no completion check was requested. Reuses the
|
|
1070
|
+
* shipped LLM-as-judge (same one `runUntil` drives). @public
|
|
1071
|
+
*/
|
|
1072
|
+
completionCheck?: CompletionCheckResult;
|
|
1055
1073
|
}
|
|
1056
1074
|
/**
|
|
1057
1075
|
* Doom-loop guard thresholds (see {@link SendOptions.doomLoop}). Both are counts of CONSECUTIVE
|
|
@@ -1324,6 +1342,57 @@ interface SendOptions {
|
|
|
1324
1342
|
* @public
|
|
1325
1343
|
*/
|
|
1326
1344
|
maxIterations?: number;
|
|
1345
|
+
/**
|
|
1346
|
+
* SE34 — per-send completion check (`isTaskComplete`). After this single
|
|
1347
|
+
* `send()` reaches a terminal `finished` state, the shipped LLM-as-judge
|
|
1348
|
+
* scores the final reply against `criteria` and surfaces the verdict on
|
|
1349
|
+
* {@link RunResult.completionCheck} + a `completion_check` run-event. This is
|
|
1350
|
+
* the finer-grained, single-`send()` gate (contrast `runUntil`, which judges
|
|
1351
|
+
* the FULL response BETWEEN sends). Opt-in — absent ⇒ the send is byte-identical
|
|
1352
|
+
* to today (no extra judge call). Non-finished runs skip the check. The judge
|
|
1353
|
+
* runs when `wait()` is called on the returned `Run`; a stream-only consumer
|
|
1354
|
+
* must call `wait()` to trigger the verdict + the `completion_check` event.
|
|
1355
|
+
*
|
|
1356
|
+
* @public
|
|
1357
|
+
*/
|
|
1358
|
+
completionCheck?: CompletionCheck;
|
|
1359
|
+
/**
|
|
1360
|
+
* SE34 — project the standing durable objective (SE33) for this `threadId`
|
|
1361
|
+
* into the model context for this send as `<current-objective>…`, so the
|
|
1362
|
+
* model always sees what it is working toward. Opt-in — absent ⇒ the assembled
|
|
1363
|
+
* system prompt is byte-identical to today. Only an ACTIVE objective is
|
|
1364
|
+
* projected (`done`/`paused` ⇒ nothing injected). Reuses the SE33 objective
|
|
1365
|
+
* store + the system-prompt assembly seam (no general signal framework — YAGNI).
|
|
1366
|
+
*
|
|
1367
|
+
* @public
|
|
1368
|
+
*/
|
|
1369
|
+
objectiveThreadId?: string;
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* SE34 — the per-send completion criterion (see {@link SendOptions.completionCheck}).
|
|
1373
|
+
*
|
|
1374
|
+
* @public
|
|
1375
|
+
*/
|
|
1376
|
+
interface CompletionCheck {
|
|
1377
|
+
/** What "complete" means for this send — fed to the judge as the goal. */
|
|
1378
|
+
criteria: string;
|
|
1379
|
+
/** Judge model identifier. Default `"openai/gpt-4o-mini"`. */
|
|
1380
|
+
judgeModel?: string;
|
|
1381
|
+
/** Override env for the judge auxiliary agent. Default `OPENROUTER_API_KEY`. */
|
|
1382
|
+
apiKey?: string;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* SE34 — the resolved per-send completion verdict (see {@link RunResult.completionCheck}).
|
|
1386
|
+
*
|
|
1387
|
+
* @public
|
|
1388
|
+
*/
|
|
1389
|
+
interface CompletionCheckResult {
|
|
1390
|
+
/** `true` when the judge ruled the send's reply satisfies the criteria. */
|
|
1391
|
+
complete: boolean;
|
|
1392
|
+
/** The judge's stated reason. */
|
|
1393
|
+
reason: string;
|
|
1394
|
+
/** `true` when the judge output could not be parsed — fail-safe `complete: false`. */
|
|
1395
|
+
parseFailed: boolean;
|
|
1327
1396
|
}
|
|
1328
1397
|
/**
|
|
1329
1398
|
* Handle to a single prompt submission.
|
|
@@ -1397,4 +1466,4 @@ interface GenerateRunResult<O> {
|
|
|
1397
1466
|
};
|
|
1398
1467
|
}
|
|
1399
1468
|
|
|
1400
|
-
export { type
|
|
1469
|
+
export { type SDKImageDimension as $, type AgentConversationTurn as A, type RunEvent as B, type CustomTool as C, type DoomLoopThresholds as D, type RunEventSink as E, type RunGitInfo as F, type GenerateOptions as G, type RunOperation as H, type ImageBlock as I, type RunPermissionDeniedEvent as J, type RunRateLimitEvent as K, type RunStatus as L, type ModelSelection as M, type RunTaskCompletedEvent as N, type OutputProcessorContext as O, type Processor as P, type RunTaskStartedEvent as Q, type RunResult as R, type SDKMessage as S, type ToolResultContentBlock as T, type RunTaskUpdatedEvent as U, type RunToCompletionOptions as V, type RunToCompletionResult as W, type RunToolProgressEvent as X, type RunTripwireEvent as Y, type SDKAssistantMessage as Z, type SDKImage as _, type McpServerConfig as a, type SDKObjectDelta as a0, type SDKRequestMessage as a1, type SDKStatusMessage as a2, type SDKSystemMessage as a3, type SDKTaskMessage as a4, type SDKThinkingMessage as a5, type SDKToolUseMessage as a6, type SDKUserMessage as a7, type SDKUserMessageEvent as a8, type SendOptions as a9, type UserMessageAppendedUpdate as aA, emitRunEvent as aB, type ShellCommand as aa, type ShellConversationTurn as ab, type ShellOutput as ac, type ShellOutputDeltaUpdate as ad, type StepCompletedUpdate as ae, type StepStartedUpdate as af, type StreamToCompletionResult as ag, type SummaryCompletedUpdate as ah, type SummaryStartedUpdate as ai, type SummaryUpdate as aj, type TextBlock as ak, type TextDeltaUpdate as al, type ThinkingCompletedUpdate as am, type ThinkingDeltaUpdate as an, type ThinkingMessage as ao, type TokenDeltaUpdate as ap, type TokenUsage as aq, type ToolCall as ar, type ToolCallCompletedUpdate as as, type ToolCallStartedUpdate as at, type ToolContextMessage as au, type ToolResult as av, type ToolResultGuardOptions as aw, type ToolUseBlock as ax, type TurnEndedUpdate as ay, type UserMessage as az, type Run as b, type MessageOrigin as c, type AssistantMessage as d, type CompletionCheck as e, type CompletionCheckResult as f, type ConversationStep as g, type ConversationTurn as h, type CostBreakdown as i, type CostSource as j, type CostStatus as k, type GenerateRunResult as l, type InputProcessorContext as m, type InteractionUpdate as n, type McpAuthConfig as o, type McpHttpServerConfig as p, type McpOAuthConfig as q, type McpStdioServerConfig as r, type ModelParameterValue as s, type PartialToolCallUpdate as t, type ProcessorControls as u, type ProcessorTripwire as v, type ProcessorViolation as w, type RunCompactBoundaryEvent as x, type RunCompletionCheckEvent as y, type RunErrorDetail as z };
|
package/dist/types/agent.d.ts
CHANGED
|
@@ -404,6 +404,14 @@ export interface AgentOptions {
|
|
|
404
404
|
outputProcessors?: readonly import("./processors.js").Processor[];
|
|
405
405
|
/** Memory configuration. Persists durable facts; auto-recalled on send. */
|
|
406
406
|
memory?: MemorySettings;
|
|
407
|
+
/**
|
|
408
|
+
* SE33 — standing goal config for a DURABLE, thread-scoped objective (Mastra
|
|
409
|
+
* Goals parity). Read when a durable objective (`setObjective`) is set: the
|
|
410
|
+
* per-objective values take precedence over this config, which takes
|
|
411
|
+
* precedence over the built-in defaults. The judge is the activation switch —
|
|
412
|
+
* with no `judgeModel` resolved, a standing objective is inert. ADR 0012.
|
|
413
|
+
*/
|
|
414
|
+
goal?: import("./objective.js").AgentGoalConfig;
|
|
407
415
|
/**
|
|
408
416
|
* Inline custom tools. Local runtime only — cloud agents reject any non-empty
|
|
409
417
|
* `tools` array. Handlers are not persisted; pass them again on resume.
|
|
@@ -703,7 +711,30 @@ export interface SDKAgent {
|
|
|
703
711
|
*
|
|
704
712
|
* @public
|
|
705
713
|
*/
|
|
706
|
-
runUntil?(goal
|
|
714
|
+
runUntil?(goal?: string, options?: import("./goal-events.js").GoalOptions): import("./goal-events.js").RunUntilIterator;
|
|
715
|
+
/**
|
|
716
|
+
* SE33 — set a DURABLE, thread-scoped objective persisted via the
|
|
717
|
+
* conversation storage (survives reload). Read by `runUntil()` when no
|
|
718
|
+
* explicit goal is passed. `threadId` is REQUIRED (the durability key); the
|
|
719
|
+
* call no-ops when the run is not memory-backed (the storage adapter omits the
|
|
720
|
+
* optional objective methods). Throws `ConfigurationError` on `maxRuns <= 0`.
|
|
721
|
+
* ADR 0012.
|
|
722
|
+
*/
|
|
723
|
+
setObjective?(objective: string, opts: {
|
|
724
|
+
threadId: string;
|
|
725
|
+
} & import("./objective.js").DurableGoalOptions): Promise<void>;
|
|
726
|
+
/** SE33 — read the durable objective record for a thread (or `undefined`). */
|
|
727
|
+
getObjective?(opts: {
|
|
728
|
+
threadId: string;
|
|
729
|
+
}): Promise<import("./objective.js").ObjectiveRecord | undefined>;
|
|
730
|
+
/** SE33 — merge options into the active objective (only provided fields change; no-op if unset). */
|
|
731
|
+
updateObjectiveOptions?(opts: {
|
|
732
|
+
threadId: string;
|
|
733
|
+
} & import("./objective.js").DurableGoalOptions): Promise<void>;
|
|
734
|
+
/** SE33 — drop the durable objective for a thread. */
|
|
735
|
+
clearObjective?(opts: {
|
|
736
|
+
threadId: string;
|
|
737
|
+
}): Promise<void>;
|
|
707
738
|
/**
|
|
708
739
|
* Fork a short-lived sub-agent with parent's credentials + system
|
|
709
740
|
* prompt byte-identical (ADR D112 — cache hit) and a restricted tool
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
|
+
import type { ObjectiveRecord } from "./objective.js";
|
|
12
13
|
/**
|
|
13
14
|
* Persisted message envelope used by {@link ConversationStorageAdapter}.
|
|
14
15
|
*
|
|
@@ -140,6 +141,28 @@ export interface ConversationStorageAdapter {
|
|
|
140
141
|
* lazily. Adapters that cannot store side metadata MAY omit this.
|
|
141
142
|
*/
|
|
142
143
|
setSessionMeta?(conversationId: string, patch: SessionMetaPatch): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* SE33 — optional: read the durable {@link ObjectiveRecord} for a conversation
|
|
146
|
+
* (the thread-scoped goal). Absent ⇒ the agent's objective methods no-op
|
|
147
|
+
* (typed degradation, same contract as `getSessionMeta`). ADR 0012 D1.
|
|
148
|
+
*/
|
|
149
|
+
getObjectiveRecord?(conversationId: string): Promise<ObjectiveRecord | undefined>;
|
|
150
|
+
/**
|
|
151
|
+
* SE33 — optional: write (or, with `record: null`, CLEAR) the durable
|
|
152
|
+
* objective for a conversation. MUST create the record lazily. Adapters that
|
|
153
|
+
* cannot store side state MAY omit this. ADR 0012 D1.
|
|
154
|
+
*/
|
|
155
|
+
setObjectiveRecord?(conversationId: string, record: ObjectiveRecord | null): Promise<void>;
|
|
156
|
+
/**
|
|
157
|
+
* SE33 — optional: ATOMIC read-modify-write of the durable objective. `mutate`
|
|
158
|
+
* receives the current record (or `undefined`) and returns the next record, or
|
|
159
|
+
* `null` to clear, or `undefined` to leave it unchanged. The whole get→mutate→set
|
|
160
|
+
* MUST run under the adapter's own concurrency guard (the FS adapter holds its
|
|
161
|
+
* file lock across the read AND the write) so concurrent progress write-backs
|
|
162
|
+
* on one thread cannot drop turns (TOCTOU). Adapters that omit it fall back to a
|
|
163
|
+
* non-atomic `getObjectiveRecord` + `setObjectiveRecord` pair. ADR 0012 D1.
|
|
164
|
+
*/
|
|
165
|
+
updateObjectiveRecord?(conversationId: string, mutate: (current: ObjectiveRecord | undefined) => ObjectiveRecord | null | undefined): Promise<void>;
|
|
143
166
|
/**
|
|
144
167
|
* Optional: dispose underlying handles (close DB pool, etc.).
|
|
145
168
|
* MUST be safe to call multiple times.
|
|
@@ -86,6 +86,13 @@ export interface GoalOptions {
|
|
|
86
86
|
judgeApiKey?: string;
|
|
87
87
|
/** Optional subgoals fed to the judge prompt. */
|
|
88
88
|
subgoals?: string[];
|
|
89
|
+
/**
|
|
90
|
+
* SE33 (ADR 0012) — resolve the goal from the durable thread-scoped
|
|
91
|
+
* objective when `runUntil()` is called with NO explicit goal. Also the
|
|
92
|
+
* key the loop writes `runsUsed` / `status` progress back to. Ignored when
|
|
93
|
+
* an explicit goal is passed (that path stays ephemeral).
|
|
94
|
+
*/
|
|
95
|
+
threadId?: string;
|
|
89
96
|
/**
|
|
90
97
|
* Cancel mid-loop via `AbortController.signal`. The generator yields
|
|
91
98
|
* a `status_change: paused` event and returns at the next turn
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type * from "./goal-events.js";
|
|
|
9
9
|
export type * from "./mcp.js";
|
|
10
10
|
export type * from "./memory-adapter.js";
|
|
11
11
|
export type * from "./messages.js";
|
|
12
|
+
export type * from "./objective.js";
|
|
12
13
|
export type * from "./processors.js";
|
|
13
14
|
export type * from "./providers.js";
|
|
14
15
|
export type * from "./run.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SE33 — the durable, thread-scoped objective (Mastra Goals parity, durable half).
|
|
3
|
+
*
|
|
4
|
+
* The SDK's `runUntil` goal loop (ADRs D115-D121) is per-call/transient. SE33
|
|
5
|
+
* persists an objective in conversation storage (via the optional
|
|
6
|
+
* `getObjectiveRecord`/`setObjectiveRecord` adapter methods) so it survives
|
|
7
|
+
* reloads, is managed via `Agent` methods, and is read by `runUntil` when no
|
|
8
|
+
* explicit goal is passed. See ADR 0012.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
/** Lifecycle status of a durable objective (ADR 0012 D2). */
|
|
13
|
+
export type ObjectiveStatus = "active" | "done" | "paused";
|
|
14
|
+
/**
|
|
15
|
+
* The per-objective override subset of goal options. Precedence (ADR 0012 D3):
|
|
16
|
+
* these `record.options` → the agent's standing `goal` config → built-in default.
|
|
17
|
+
* The `judgeModel` is the activation switch — with no judge resolved, the
|
|
18
|
+
* standing objective is inert (no scoring, no budget consumed).
|
|
19
|
+
*/
|
|
20
|
+
export interface DurableGoalOptions {
|
|
21
|
+
/** Max judge-gated turns before the loop stops (default 20 — the `runUntil` default). */
|
|
22
|
+
readonly maxRuns?: number;
|
|
23
|
+
/** Judge model identifier (e.g. `"openai/gpt-4o-mini"`). Absent ⇒ inherit from agent `goal` config. */
|
|
24
|
+
readonly judgeModel?: string;
|
|
25
|
+
/** Optional extra judge instruction appended to the default judge prompt. */
|
|
26
|
+
readonly prompt?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A persisted objective record. Stored under the caller's `threadId` (the
|
|
30
|
+
* conversation key). `_schemaVersion` mirrors {@link import("./workflow.js").WorkflowSnapshot}
|
|
31
|
+
* for future migration (ADR 0012 D2).
|
|
32
|
+
*/
|
|
33
|
+
export interface ObjectiveRecord {
|
|
34
|
+
readonly _schemaVersion: 1;
|
|
35
|
+
readonly objective: string;
|
|
36
|
+
readonly options?: DurableGoalOptions;
|
|
37
|
+
readonly status: ObjectiveStatus;
|
|
38
|
+
readonly runsUsed: number;
|
|
39
|
+
}
|
|
40
|
+
/** The standing `goal` config on an agent (ADR 0012 D3). Read when a durable objective is set. */
|
|
41
|
+
export interface AgentGoalConfig {
|
|
42
|
+
readonly judgeModel?: string;
|
|
43
|
+
readonly maxRuns?: number;
|
|
44
|
+
readonly prompt?: string;
|
|
45
|
+
}
|