@namzu/sdk 55.0.0 → 56.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/CHANGELOG.md +23 -0
- package/dist/compaction/serializer.d.ts.map +1 -1
- package/dist/compaction/serializer.js +27 -15
- package/dist/compaction/serializer.js.map +1 -1
- package/dist/compaction/verifier.d.ts.map +1 -1
- package/dist/compaction/verifier.js +3 -2
- package/dist/compaction/verifier.js.map +1 -1
- package/dist/constants/compaction/index.d.ts +3 -1
- package/dist/constants/compaction/index.d.ts.map +1 -1
- package/dist/constants/compaction/index.js +3 -1
- package/dist/constants/compaction/index.js.map +1 -1
- package/dist/{manager/resident/learning-cycle.d.ts → learning/cycle.d.ts} +45 -36
- package/dist/learning/cycle.d.ts.map +1 -0
- package/dist/{manager/resident/learning-cycle.js → learning/cycle.js} +52 -20
- package/dist/learning/cycle.js.map +1 -0
- package/dist/learning/deprecated.d.ts +86 -0
- package/dist/learning/deprecated.d.ts.map +1 -0
- package/dist/learning/deprecated.js +22 -0
- package/dist/learning/deprecated.js.map +1 -0
- package/dist/learning/experience-store.d.ts +35 -0
- package/dist/learning/experience-store.d.ts.map +1 -0
- package/dist/learning/experience-store.js +143 -0
- package/dist/learning/experience-store.js.map +1 -0
- package/dist/learning/experience.d.ts +150 -0
- package/dist/learning/experience.d.ts.map +1 -0
- package/dist/learning/experience.js +146 -0
- package/dist/learning/experience.js.map +1 -0
- package/dist/learning/generator.d.ts +118 -0
- package/dist/learning/generator.d.ts.map +1 -0
- package/dist/learning/generator.js +275 -0
- package/dist/learning/generator.js.map +1 -0
- package/dist/learning/leak-tripwire.d.ts +66 -0
- package/dist/learning/leak-tripwire.d.ts.map +1 -0
- package/dist/learning/leak-tripwire.js +208 -0
- package/dist/learning/leak-tripwire.js.map +1 -0
- package/dist/{manager/resident/learning-observation.d.ts → learning/observation.d.ts} +4 -4
- package/dist/learning/observation.d.ts.map +1 -0
- package/dist/{manager/resident/learning-observation.js → learning/observation.js} +3 -3
- package/dist/learning/observation.js.map +1 -0
- package/dist/{manager/resident/learning.d.ts → learning/skill.d.ts} +29 -29
- package/dist/learning/skill.d.ts.map +1 -0
- package/dist/{manager/resident/learning.js → learning/skill.js} +27 -27
- package/dist/learning/skill.js.map +1 -0
- package/dist/{manager/resident/learning-store.d.ts → learning/store.d.ts} +38 -31
- package/dist/learning/store.d.ts.map +1 -0
- package/dist/{manager/resident/learning-store.js → learning/store.js} +52 -20
- package/dist/learning/store.js.map +1 -0
- package/dist/manager/resident/activity.d.ts +30 -6
- package/dist/manager/resident/activity.d.ts.map +1 -1
- package/dist/manager/resident/activity.js.map +1 -1
- package/dist/manager/resident/agenda.d.ts +42 -12
- package/dist/manager/resident/agenda.d.ts.map +1 -1
- package/dist/manager/resident/agenda.js +9 -7
- package/dist/manager/resident/agenda.js.map +1 -1
- package/dist/manager/resident/consumption.d.ts +27 -5
- package/dist/manager/resident/consumption.d.ts.map +1 -1
- package/dist/manager/resident/consumption.js +2 -0
- package/dist/manager/resident/consumption.js.map +1 -1
- package/dist/manager/resident/delivery-window.d.ts +7 -1
- package/dist/manager/resident/delivery-window.d.ts.map +1 -1
- package/dist/manager/resident/delivery-window.js +2 -0
- package/dist/manager/resident/delivery-window.js.map +1 -1
- package/dist/manager/resident/evidence-recall.d.ts +7 -1
- package/dist/manager/resident/evidence-recall.d.ts.map +1 -1
- package/dist/manager/resident/evidence-recall.js +2 -0
- package/dist/manager/resident/evidence-recall.js.map +1 -1
- package/dist/manager/resident/history.d.ts +45 -9
- package/dist/manager/resident/history.d.ts.map +1 -1
- package/dist/manager/resident/history.js.map +1 -1
- package/dist/manager/resident/host.d.ts +44 -10
- package/dist/manager/resident/host.d.ts.map +1 -1
- package/dist/manager/resident/host.js +4 -2
- package/dist/manager/resident/host.js.map +1 -1
- package/dist/manager/resident/initiative.d.ts +32 -6
- package/dist/manager/resident/initiative.d.ts.map +1 -1
- package/dist/manager/resident/initiative.js +2 -0
- package/dist/manager/resident/initiative.js.map +1 -1
- package/dist/manager/resident/loop.d.ts +22 -4
- package/dist/manager/resident/loop.d.ts.map +1 -1
- package/dist/manager/resident/loop.js +7 -1
- package/dist/manager/resident/loop.js.map +1 -1
- package/dist/manager/resident/outbox.d.ts +42 -8
- package/dist/manager/resident/outbox.d.ts.map +1 -1
- package/dist/manager/resident/outbox.js +2 -0
- package/dist/manager/resident/outbox.js.map +1 -1
- package/dist/manager/resident/proposal.d.ts +17 -3
- package/dist/manager/resident/proposal.d.ts.map +1 -1
- package/dist/manager/resident/proposal.js +2 -0
- package/dist/manager/resident/proposal.js.map +1 -1
- package/dist/manager/resident/store.d.ts +27 -5
- package/dist/manager/resident/store.d.ts.map +1 -1
- package/dist/manager/resident/store.js +7 -1
- package/dist/manager/resident/store.js.map +1 -1
- package/dist/manager/resident/tool-evidence.d.ts +45 -9
- package/dist/manager/resident/tool-evidence.d.ts.map +1 -1
- package/dist/manager/resident/tool-evidence.js +5 -1
- package/dist/manager/resident/tool-evidence.js.map +1 -1
- package/dist/prompt/resident-learning.d.ts +12 -2
- package/dist/prompt/resident-learning.d.ts.map +1 -1
- package/dist/prompt/resident-learning.js +6 -5
- package/dist/prompt/resident-learning.js.map +1 -1
- package/dist/prompt/resident-step.d.ts +10 -4
- package/dist/prompt/resident-step.d.ts.map +1 -1
- package/dist/prompt/resident-step.js +6 -4
- package/dist/prompt/resident-step.js.map +1 -1
- package/dist/public-runtime.d.ts +9 -3
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +10 -3
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-types.d.ts +9 -4
- package/dist/public-types.d.ts.map +1 -1
- package/dist/runtime/query/file-evidence-context.d.ts +4 -0
- package/dist/runtime/query/file-evidence-context.d.ts.map +1 -1
- package/dist/runtime/query/file-evidence-context.js +5 -1
- package/dist/runtime/query/file-evidence-context.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +2 -0
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +19 -11
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts +9 -0
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.js +19 -0
- package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +4 -1
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/step-context.d.ts +42 -0
- package/dist/runtime/query/iteration/step-context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/step-context.js +114 -0
- package/dist/runtime/query/iteration/step-context.js.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.d.ts +9 -1
- package/dist/runtime/query/iteration/step-shaping.d.ts.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.js +21 -11
- package/dist/runtime/query/iteration/step-shaping.js.map +1 -1
- package/dist/runtime/query/steering.d.ts +13 -0
- package/dist/runtime/query/steering.d.ts.map +1 -1
- package/dist/runtime/query/steering.js +42 -0
- package/dist/runtime/query/steering.js.map +1 -1
- package/dist/scheduler/completion-inbox.js +1 -1
- package/dist/scheduler/completion-inbox.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts +3 -5
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +14 -15
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/edit.js +1 -1
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/env-scrub.d.ts +8 -0
- package/dist/tools/env-scrub.d.ts.map +1 -1
- package/dist/tools/env-scrub.js +13 -0
- package/dist/tools/env-scrub.js.map +1 -1
- package/dist/tools/resident-history.d.ts +2 -0
- package/dist/tools/resident-history.d.ts.map +1 -1
- package/dist/tools/resident-history.js +2 -0
- package/dist/tools/resident-history.js.map +1 -1
- package/dist/tools/resident-tool-evidence.d.ts +5 -1
- package/dist/tools/resident-tool-evidence.d.ts.map +1 -1
- package/dist/tools/resident-tool-evidence.js +5 -1
- package/dist/tools/resident-tool-evidence.js.map +1 -1
- package/dist/turn/evidence-recall.d.ts +15 -3
- package/dist/turn/evidence-recall.d.ts.map +1 -1
- package/dist/turn/evidence-recall.js +116 -27
- package/dist/turn/evidence-recall.js.map +1 -1
- package/dist/types/message/notice-frame.d.ts +1 -1
- package/dist/types/message/notice-frame.d.ts.map +1 -1
- package/dist/types/message/notice-frame.js +1 -0
- package/dist/types/message/notice-frame.js.map +1 -1
- package/package.json +1 -1
- package/src/compaction/serializer.ts +29 -17
- package/src/compaction/verifier.ts +3 -2
- package/src/constants/compaction/index.ts +3 -1
- package/src/{manager/resident/learning-cycle.ts → learning/cycle.ts} +130 -78
- package/src/learning/deprecated.ts +124 -0
- package/src/learning/experience-store.ts +202 -0
- package/src/learning/experience.ts +238 -0
- package/src/learning/generator.ts +388 -0
- package/src/learning/leak-tripwire.ts +280 -0
- package/src/{manager/resident/learning-observation.ts → learning/observation.ts} +5 -5
- package/src/{manager/resident/learning.ts → learning/skill.ts} +64 -67
- package/src/{manager/resident/learning-store.ts → learning/store.ts} +97 -67
- package/src/manager/resident/activity.ts +30 -6
- package/src/manager/resident/agenda.ts +63 -33
- package/src/manager/resident/consumption.ts +27 -5
- package/src/manager/resident/delivery-window.ts +7 -1
- package/src/manager/resident/evidence-recall.ts +7 -1
- package/src/manager/resident/history.ts +45 -9
- package/src/manager/resident/host.ts +45 -11
- package/src/manager/resident/initiative.ts +32 -6
- package/src/manager/resident/loop.ts +22 -4
- package/src/manager/resident/outbox.ts +42 -8
- package/src/manager/resident/proposal.ts +17 -3
- package/src/manager/resident/store.ts +27 -5
- package/src/manager/resident/tool-evidence.ts +45 -9
- package/src/prompt/resident-learning.ts +16 -7
- package/src/prompt/resident-step.ts +19 -13
- package/src/public-runtime.ts +35 -5
- package/src/public-types.ts +96 -34
- package/src/runtime/query/file-evidence-context.ts +8 -1
- package/src/runtime/query/iteration/index.ts +27 -13
- package/src/runtime/query/iteration/phases/per-call-review.ts +19 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +3 -0
- package/src/runtime/query/iteration/step-context.ts +138 -0
- package/src/runtime/query/iteration/step-shaping.ts +39 -13
- package/src/runtime/query/steering.ts +51 -0
- package/src/scheduler/completion-inbox.ts +1 -1
- package/src/tools/builtins/bash.ts +14 -14
- package/src/tools/builtins/edit.ts +1 -1
- package/src/tools/env-scrub.ts +13 -0
- package/src/tools/resident-history.ts +2 -0
- package/src/tools/resident-tool-evidence.ts +5 -1
- package/src/turn/evidence-recall.ts +125 -30
- package/src/types/message/notice-frame.ts +3 -1
- package/dist/manager/resident/learning-cycle.d.ts.map +0 -1
- package/dist/manager/resident/learning-cycle.js.map +0 -1
- package/dist/manager/resident/learning-observation.d.ts.map +0 -1
- package/dist/manager/resident/learning-observation.js.map +0 -1
- package/dist/manager/resident/learning-store.d.ts.map +0 -1
- package/dist/manager/resident/learning-store.js.map +0 -1
- package/dist/manager/resident/learning.d.ts.map +0 -1
- package/dist/manager/resident/learning.js.map +0 -1
|
@@ -28,7 +28,11 @@ export const residentDecisionSchema = z.discriminatedUnion('kind', [
|
|
|
28
28
|
z.object({ kind: z.literal('blocked'), summary: text }),
|
|
29
29
|
])
|
|
30
30
|
|
|
31
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* @experimental One bounded step's durable disposition; silence is not completion.
|
|
33
|
+
*
|
|
34
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
35
|
+
*/
|
|
32
36
|
export type ResidentDecision = z.infer<typeof residentDecisionSchema>
|
|
33
37
|
|
|
34
38
|
export const residentStateSchema = z
|
|
@@ -69,7 +73,11 @@ export const residentStateSchema = z
|
|
|
69
73
|
}
|
|
70
74
|
})
|
|
71
75
|
|
|
72
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* @experimental Persisted identity and one pursuit, independent of a conversation.
|
|
78
|
+
*
|
|
79
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
80
|
+
*/
|
|
73
81
|
export type ResidentState = Readonly<z.infer<typeof residentStateSchema>>
|
|
74
82
|
|
|
75
83
|
/** Bounded addressing for local resident state. Stored scope is still validated. */
|
|
@@ -80,10 +88,18 @@ export function residentKeySegment(key: string): string {
|
|
|
80
88
|
: `~sha256-${createHash('sha256').update(encoded).digest('hex')}`
|
|
81
89
|
}
|
|
82
90
|
|
|
83
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* @experimental Minimal atomic contract needed to execute an existing pursuit.
|
|
93
|
+
*
|
|
94
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
95
|
+
*/
|
|
84
96
|
export type ResidentExecutionStore = Pick<ResidentStore, 'read' | 'claim' | 'settle'>
|
|
85
97
|
|
|
86
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* @experimental Backends must atomically compare revisions and publish admission before work.
|
|
100
|
+
*
|
|
101
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
102
|
+
*/
|
|
87
103
|
export interface ResidentStore {
|
|
88
104
|
read(): Promise<ResidentState | null>
|
|
89
105
|
create(identity: string, objective: string): Promise<ResidentState>
|
|
@@ -92,7 +108,11 @@ export interface ResidentStore {
|
|
|
92
108
|
wake(expected: ResidentState, reason: string, now: number): Promise<ResidentState>
|
|
93
109
|
}
|
|
94
110
|
|
|
95
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* A competing owner advanced this resident's immutable revision.
|
|
113
|
+
*
|
|
114
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
115
|
+
*/
|
|
96
116
|
export class ResidentConflictError extends Error {
|
|
97
117
|
constructor() {
|
|
98
118
|
super('Resident state changed; read the current state before retrying.')
|
|
@@ -104,6 +124,8 @@ export class ResidentConflictError extends Error {
|
|
|
104
124
|
* @experimental Local-filesystem state for one tenant/agent key and one pursuit.
|
|
105
125
|
* A running claim never expires automatically: a crashed step may have effects.
|
|
106
126
|
* Uses exclusive immutable revision publication, not a read/rename lock.
|
|
127
|
+
*
|
|
128
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
107
129
|
*/
|
|
108
130
|
export class DiskResidentStore implements ResidentStore {
|
|
109
131
|
private readonly records = new DiskRevisionRecordStore<ResidentState>(
|
|
@@ -17,16 +17,28 @@ import type {
|
|
|
17
17
|
ResidentHistorySource,
|
|
18
18
|
} from './history.js'
|
|
19
19
|
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* @experimental Host authority for one pursuit, project and admission boundary.
|
|
22
|
+
*
|
|
23
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
24
|
+
*/
|
|
21
25
|
export interface ResidentToolEvidenceScope extends ResidentHistoryScope {
|
|
22
26
|
readonly projectId: string
|
|
23
27
|
}
|
|
24
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* @experimental Identity of an agenda-verified settlement, not a fabricated transcript.
|
|
30
|
+
*
|
|
31
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
32
|
+
*/
|
|
25
33
|
export type ResidentSettledInvocation = Pick<
|
|
26
34
|
ResidentHistoryMatch,
|
|
27
35
|
'revision' | 'claimId' | 'step' | 'kind'
|
|
28
36
|
>
|
|
29
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* @experimental Settlement is checked before the host resolves the attempt's invocation.
|
|
39
|
+
*
|
|
40
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
41
|
+
*/
|
|
30
42
|
export interface ResidentToolEvidenceOptions {
|
|
31
43
|
readonly history: ResidentHistorySource
|
|
32
44
|
readonly projectId: string
|
|
@@ -45,7 +57,11 @@ export interface ResidentToolEvidenceOptions {
|
|
|
45
57
|
signal?: AbortSignal,
|
|
46
58
|
) => Promise<SessionEvidenceSource>
|
|
47
59
|
}
|
|
48
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* @experimental An optional shared ceiling covers history, resolution and turn evidence.
|
|
62
|
+
*
|
|
63
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
64
|
+
*/
|
|
49
65
|
export interface ResidentToolEvidenceSearchOptions {
|
|
50
66
|
readonly query?: string
|
|
51
67
|
/** Token discovery: 1–16 terms, matched case-insensitively. Combined query/filter JSON ≤512 UTF-8 bytes. */
|
|
@@ -60,7 +76,11 @@ export interface ResidentToolEvidenceSearchOptions {
|
|
|
60
76
|
readonly refineTerms?: readonly string[]
|
|
61
77
|
readonly maxReadBytes?: number
|
|
62
78
|
}
|
|
63
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* @experimental Tool records from at most one settled invocation per bounded search page.
|
|
81
|
+
*
|
|
82
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
83
|
+
*/
|
|
64
84
|
export interface ResidentToolEvidenceSearchResult {
|
|
65
85
|
readonly scope: ResidentToolEvidenceScope
|
|
66
86
|
readonly revision: number | null
|
|
@@ -75,20 +95,32 @@ export interface ResidentToolEvidenceSearchResult {
|
|
|
75
95
|
*/
|
|
76
96
|
readonly chargedBytes?: number
|
|
77
97
|
}
|
|
78
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* @experimental The revision is authorized anew on every read, including after restart.
|
|
100
|
+
*
|
|
101
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
102
|
+
*/
|
|
79
103
|
export interface ResidentToolEvidenceReadOptions
|
|
80
104
|
extends Omit<SessionEvidenceReadOptions, 'maxReadBytes'> {
|
|
81
105
|
readonly revision: number
|
|
82
106
|
/** Shared operation ceiling, at most 8 MiB; reserves at least 1 MiB for turn evidence reads. */
|
|
83
107
|
readonly maxReadBytes?: number
|
|
84
108
|
}
|
|
85
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* @experimental Exact invocation text plus the settled claim that authorized access.
|
|
111
|
+
*
|
|
112
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
113
|
+
*/
|
|
86
114
|
export interface ResidentToolEvidenceReadResult extends SessionEvidenceReadResult {
|
|
87
115
|
readonly revision: number
|
|
88
116
|
readonly claimId: string
|
|
89
117
|
readonly chargedBytes?: number
|
|
90
118
|
}
|
|
91
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* @experimental A host must bind tool access to the executing turn, not just this source.
|
|
121
|
+
*
|
|
122
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
123
|
+
*/
|
|
92
124
|
export interface ResidentToolEvidenceSource {
|
|
93
125
|
readonly scope: ResidentToolEvidenceScope
|
|
94
126
|
readonly supportsTermRefinement?: boolean
|
|
@@ -102,7 +134,11 @@ export interface ResidentToolEvidenceSource {
|
|
|
102
134
|
): Promise<ResidentToolEvidenceReadResult>
|
|
103
135
|
}
|
|
104
136
|
|
|
105
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* @experimental Reuses the immutable agenda boundary; it never enumerates arbitrary sessions.
|
|
139
|
+
*
|
|
140
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
141
|
+
*/
|
|
106
142
|
export function createResidentToolEvidenceSource(
|
|
107
143
|
options: ResidentToolEvidenceOptions,
|
|
108
144
|
): ResidentToolEvidenceSource {
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
|
-
import {
|
|
2
|
+
import { freezeLearning, projectLearning } from '../learning/skill.js'
|
|
3
3
|
import { defineTool } from '../tools/defineTool.js'
|
|
4
4
|
import type { ToolContext, ToolDefinition } from '../types/tool/index.js'
|
|
5
5
|
import type { PromptContribution } from './contributions.js'
|
|
6
6
|
import { type ResidentStepPromptOptions, createResidentStepContributions } from './resident-step.js'
|
|
7
7
|
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* @experimental One admission's context and read-only access to its evaluated guidance.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
12
|
+
*/
|
|
9
13
|
export interface ResidentStepContextBundle {
|
|
10
14
|
readonly contributions: readonly PromptContribution[]
|
|
11
15
|
readonly tools: readonly ToolDefinition[]
|
|
12
16
|
}
|
|
13
17
|
|
|
14
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* @experimental The host must reject reads from runs outside the admitted scope.
|
|
20
|
+
*
|
|
21
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
22
|
+
*/
|
|
15
23
|
export interface ResidentStepContextOptions extends ResidentStepPromptOptions {
|
|
16
24
|
readonly authorizeLearningRead: (context: ToolContext) => boolean
|
|
17
25
|
}
|
|
@@ -20,11 +28,13 @@ export interface ResidentStepContextOptions extends ResidentStepPromptOptions {
|
|
|
20
28
|
* @experimental List guidance descriptions first; disclose complete bodies only
|
|
21
29
|
* when requested. Selection is local to this admission, never persisted as a
|
|
22
30
|
* preference or inferred from keywords. Mount both returned tools and context.
|
|
31
|
+
*
|
|
32
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
23
33
|
*/
|
|
24
34
|
export function createResidentStepContext(
|
|
25
35
|
options: ResidentStepContextOptions,
|
|
26
36
|
): ResidentStepContextBundle {
|
|
27
|
-
const learning = options.learning ?
|
|
37
|
+
const learning = options.learning ? freezeLearning(options.learning) : undefined
|
|
28
38
|
const contributions = createResidentStepContributions({
|
|
29
39
|
...options,
|
|
30
40
|
learning: learning ? { ...learning, skills: [] } : undefined,
|
|
@@ -35,8 +45,7 @@ export function createResidentStepContext(
|
|
|
35
45
|
const authorize = options.authorizeLearningRead
|
|
36
46
|
const resolveSources = options.resolveLearningSources
|
|
37
47
|
const selected = new Set<string>()
|
|
38
|
-
const profileChars =
|
|
39
|
-
.length
|
|
48
|
+
const profileChars = projectLearning(learning, { maxChars: 12_000, skillNames: [] }).text.length
|
|
40
49
|
const project = (names: readonly string[], maxChars = 12_000) => {
|
|
41
50
|
let sources: ReturnType<NonNullable<typeof resolveSources>> = []
|
|
42
51
|
try {
|
|
@@ -44,7 +53,7 @@ export function createResidentStepContext(
|
|
|
44
53
|
} catch {
|
|
45
54
|
// Unavailable observations cannot establish a dependency match.
|
|
46
55
|
}
|
|
47
|
-
return
|
|
56
|
+
return projectLearning(
|
|
48
57
|
{ ...learning, identity: undefined, preferences: [] },
|
|
49
58
|
{ maxChars, skillNames: names, sources },
|
|
50
59
|
)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ResidentHistoryScope } from '../manager/resident/history.js'
|
|
2
1
|
import {
|
|
3
|
-
type
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '../
|
|
2
|
+
type LearningSource,
|
|
3
|
+
type LearningState,
|
|
4
|
+
freezeLearning,
|
|
5
|
+
projectLearning,
|
|
6
|
+
} from '../learning/skill.js'
|
|
7
|
+
import type { ResidentHistoryScope } from '../manager/resident/history.js'
|
|
8
8
|
import type { ResidentState } from '../manager/resident/store.js'
|
|
9
9
|
import type { PromptContribution } from './contributions.js'
|
|
10
10
|
|
|
@@ -34,13 +34,17 @@ Use permitted reads and analysis. Do not change files, persistent memory or exte
|
|
|
34
34
|
const HISTORY_GUIDANCE = `## Resident recall
|
|
35
35
|
When the saved summary lacks an earlier decision or accepted input, use search_resident_history, then read_resident_history for exact retained text. Search without a query to browse recent steps. Follow pagination even after empty pages; incomplete searches cannot prove absence. Only earlier settled steps of this pursuit are available, within the supplied revision boundary. Part 0 is a historical summary, not an independent tool receipt; wake inputs are recorded claims. Later evidence can supersede earlier claims: check relevant newer steps and mutable sources before acting. Do not repeat an effect to recover its output. These tools do not restore unrecorded tool transcripts.`
|
|
36
36
|
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* @experimental Host-selected context for one admitted resident step.
|
|
39
|
+
*
|
|
40
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
41
|
+
*/
|
|
38
42
|
export interface ResidentStepPromptOptions {
|
|
39
43
|
readonly state: ResidentState
|
|
40
44
|
/** The host-approved learning snapshot bound to this admission. */
|
|
41
|
-
readonly learning?:
|
|
45
|
+
readonly learning?: LearningState
|
|
42
46
|
/** Host resolves current dependency revisions for each model request. No model-generated revisions. */
|
|
43
|
-
readonly resolveLearningSources?: () => readonly
|
|
47
|
+
readonly resolveLearningSources?: () => readonly LearningSource[]
|
|
44
48
|
/** Bound historical source whose read-only tools the host has mounted. */
|
|
45
49
|
readonly history?: ResidentHistoryScope
|
|
46
50
|
/** The host mounted scoped search_resident_tools/read_resident_tool capabilities. */
|
|
@@ -64,6 +68,8 @@ export interface ResidentStepPromptOptions {
|
|
|
64
68
|
*
|
|
65
69
|
* Project instructions and authorization remain on their existing host/runtime
|
|
66
70
|
* paths. These contributions neither load project files nor authorize work.
|
|
71
|
+
*
|
|
72
|
+
* @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
|
|
67
73
|
*/
|
|
68
74
|
export function createResidentStepContributions(
|
|
69
75
|
options: ResidentStepPromptOptions,
|
|
@@ -76,11 +82,11 @@ export function createResidentStepContributions(
|
|
|
76
82
|
options.history.pursuitId !== state.pursuitId)
|
|
77
83
|
)
|
|
78
84
|
throw new Error('Resident history context belongs to a different pursuit.')
|
|
79
|
-
const admittedLearning = options.learning ?
|
|
85
|
+
const admittedLearning = options.learning ? freezeLearning(options.learning) : undefined
|
|
80
86
|
const boundNames =
|
|
81
87
|
admittedLearning?.skills.filter((skill) => skill.sources?.length).map((skill) => skill.name) ??
|
|
82
88
|
[]
|
|
83
|
-
const learning =
|
|
89
|
+
const learning = projectLearning(admittedLearning, {
|
|
84
90
|
maxChars: 12_000,
|
|
85
91
|
skillNames:
|
|
86
92
|
admittedLearning?.skills
|
|
@@ -137,13 +143,13 @@ export function createResidentStepContributions(
|
|
|
137
143
|
id: 'namzu.resident-step.source-bound-learning',
|
|
138
144
|
placement: 'context' as const,
|
|
139
145
|
render: () => {
|
|
140
|
-
let sources: readonly
|
|
146
|
+
let sources: readonly LearningSource[] = []
|
|
141
147
|
try {
|
|
142
148
|
sources = resolveSources?.() ?? []
|
|
143
149
|
} catch {
|
|
144
150
|
/* Unavailable evidence withholds bound instructions. */
|
|
145
151
|
}
|
|
146
|
-
const projection =
|
|
152
|
+
const projection = projectLearning(
|
|
147
153
|
admittedLearning
|
|
148
154
|
? { ...admittedLearning, identity: undefined, preferences: [] }
|
|
149
155
|
: undefined,
|
package/src/public-runtime.ts
CHANGED
|
@@ -1473,6 +1473,8 @@ export {
|
|
|
1473
1473
|
} from './runtime/query/auto-review/index.js'
|
|
1474
1474
|
// What the model is told when a person declines a call without words of their own.
|
|
1475
1475
|
export { DECLINED_TOOL_CALL_FEEDBACK } from './runtime/query/declined.js'
|
|
1476
|
+
// Whether a tool result answers a call the review did not let run, so a host counting failures can leave it out.
|
|
1477
|
+
export { isReviewRefusalResult } from './runtime/query/iteration/phases/per-call-review.js'
|
|
1476
1478
|
|
|
1477
1479
|
// The system prompt is open: a contribution registry the assembler
|
|
1478
1480
|
// consumes, with skills as its first contributor. See `prompt/contributions.ts`.
|
|
@@ -1651,11 +1653,31 @@ export { validateResidentProposal } from './manager/resident/proposal.js'
|
|
|
1651
1653
|
export { deliverResidentMessage } from './manager/resident/outbox.js'
|
|
1652
1654
|
export { createResidentDeliveryWindow } from './manager/resident/delivery-window.js'
|
|
1653
1655
|
|
|
1656
|
+
export { hashLearningSkill, projectLearning } from './learning/skill.js'
|
|
1657
|
+
export { runLearningCycle } from './learning/cycle.js'
|
|
1654
1658
|
export {
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
+
LEARNING_FLOOR_COMPONENTS,
|
|
1660
|
+
LEARNING_SURFACE_KINDS,
|
|
1661
|
+
learningExperienceFromCycle,
|
|
1662
|
+
proposeLearningCandidate,
|
|
1663
|
+
resolveLearningSurface,
|
|
1664
|
+
} from './learning/generator.js'
|
|
1665
|
+
export {
|
|
1666
|
+
LEARNING_CONFIDENCE_LEVELS,
|
|
1667
|
+
LEARNING_EDIT_VERDICTS,
|
|
1668
|
+
normalizeLearningExperience,
|
|
1669
|
+
selectLearningExperience,
|
|
1670
|
+
} from './learning/experience.js'
|
|
1671
|
+
export {
|
|
1672
|
+
LEARNING_EXPERIENCE_STORE_VERSION,
|
|
1673
|
+
SqliteLearningExperienceStore,
|
|
1674
|
+
} from './learning/experience-store.js'
|
|
1675
|
+
export {
|
|
1676
|
+
LearningLeakError,
|
|
1677
|
+
assertNoLearningLeak,
|
|
1678
|
+
createLearningCanary,
|
|
1679
|
+
scanForLearningLeak,
|
|
1680
|
+
} from './learning/leak-tripwire.js'
|
|
1659
1681
|
|
|
1660
1682
|
export {
|
|
1661
1683
|
createSessionEvidenceSource,
|
|
@@ -1670,11 +1692,19 @@ export { createResidentToolEvidenceSource } from './manager/resident/tool-eviden
|
|
|
1670
1692
|
|
|
1671
1693
|
export { createResidentEvidenceRecallStep } from './manager/resident/evidence-recall.js'
|
|
1672
1694
|
|
|
1695
|
+
export {
|
|
1696
|
+
SqliteLearningStore,
|
|
1697
|
+
runStoredLearningCycle,
|
|
1698
|
+
runStoredLearningFromObservations,
|
|
1699
|
+
} from './learning/store.js'
|
|
1673
1700
|
export {
|
|
1674
1701
|
SqliteResidentLearningStore,
|
|
1702
|
+
hashResidentSkill,
|
|
1703
|
+
projectResidentLearning,
|
|
1704
|
+
runResidentLearningCycle,
|
|
1675
1705
|
runStoredResidentLearningCycle,
|
|
1676
1706
|
runStoredResidentLearningFromObservations,
|
|
1677
|
-
} from './
|
|
1707
|
+
} from './learning/deprecated.js'
|
|
1678
1708
|
|
|
1679
1709
|
// ─── sessions, turns and the session log ─────────────────────────────────
|
|
1680
1710
|
//
|
package/src/public-types.ts
CHANGED
|
@@ -607,29 +607,58 @@ export type {
|
|
|
607
607
|
ResidentContextualStep,
|
|
608
608
|
} from './manager/resident/host.js'
|
|
609
609
|
export type {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
} from './
|
|
620
|
-
export type {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
} from './
|
|
610
|
+
LearningEvidence,
|
|
611
|
+
LearningSkillCandidate,
|
|
612
|
+
LearnedSkill,
|
|
613
|
+
LearningState,
|
|
614
|
+
LearningProfileUpdate,
|
|
615
|
+
LearningSkillEvaluation,
|
|
616
|
+
LearningProjectionOptions,
|
|
617
|
+
LearningSource,
|
|
618
|
+
LearningProjection,
|
|
619
|
+
} from './learning/skill.js'
|
|
620
|
+
export type {
|
|
621
|
+
LearningStage,
|
|
622
|
+
LearningReceipt,
|
|
623
|
+
LearningConsumption,
|
|
624
|
+
LearningCycleEvent,
|
|
625
|
+
LearningCycleContext,
|
|
626
|
+
LearningGenerationContext,
|
|
627
|
+
LearningExplorationContext,
|
|
628
|
+
LearningExploration,
|
|
629
|
+
LearningEvaluationContext,
|
|
630
|
+
LearningCycleOptions,
|
|
631
|
+
LearningCycleResult,
|
|
632
|
+
} from './learning/cycle.js'
|
|
633
|
+
|
|
634
|
+
export type {
|
|
635
|
+
LearningModel,
|
|
636
|
+
LearningModelReply,
|
|
637
|
+
LearningModelRequest,
|
|
638
|
+
LearningProposal,
|
|
639
|
+
LearningProposeOptions,
|
|
640
|
+
LearningProposedEdit,
|
|
641
|
+
LearningSurface,
|
|
642
|
+
LearningSurfaceKind,
|
|
643
|
+
} from './learning/generator.js'
|
|
644
|
+
|
|
645
|
+
export type {
|
|
646
|
+
LearningConfidence,
|
|
647
|
+
LearningEditRow,
|
|
648
|
+
LearningEditVerdict,
|
|
649
|
+
LearningExperienceEntry,
|
|
650
|
+
LearningExperienceInput,
|
|
651
|
+
LearningExperienceQuery,
|
|
652
|
+
LearningLesson,
|
|
653
|
+
} from './learning/experience.js'
|
|
654
|
+
export type { SqliteLearningExperienceStoreOptions } from './learning/experience-store.js'
|
|
655
|
+
|
|
656
|
+
export type {
|
|
657
|
+
LearningLeakGuard,
|
|
658
|
+
LearningLeakKind,
|
|
659
|
+
LearningLeakFinding,
|
|
660
|
+
LearningLeakSubject,
|
|
661
|
+
} from './learning/leak-tripwire.js'
|
|
633
662
|
|
|
634
663
|
export type {
|
|
635
664
|
ResidentArchiveRequest,
|
|
@@ -678,18 +707,18 @@ export type {
|
|
|
678
707
|
} from './turn/json-claim-verifier.js'
|
|
679
708
|
|
|
680
709
|
export type {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
} from './
|
|
710
|
+
SqliteLearningStoreOptions,
|
|
711
|
+
LearningArtifact,
|
|
712
|
+
LearningRecordedUsage,
|
|
713
|
+
LearningCycleSummary,
|
|
714
|
+
LearningDiscoveryOptions,
|
|
715
|
+
LearningDiscoveryResult,
|
|
716
|
+
} from './learning/store.js'
|
|
688
717
|
export type {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
} from './
|
|
718
|
+
LearningObservation,
|
|
719
|
+
LearningObservationRecord,
|
|
720
|
+
LearningTarget,
|
|
721
|
+
} from './learning/observation.js'
|
|
693
722
|
|
|
694
723
|
// ─── sessions, turns and the session log: paths and log lines ────────────
|
|
695
724
|
// The session types themselves come through `./types/session/index.js` above.
|
|
@@ -818,3 +847,36 @@ export type {
|
|
|
818
847
|
} from './pals/activity/subscription-policy.js'
|
|
819
848
|
export type { PalActivitySubscriptionRunnerOptions } from './pals/activity/subscriptions.js'
|
|
820
849
|
export type { PalActivityCausalityOptions } from './pals/activity/causality.js'
|
|
850
|
+
|
|
851
|
+
// Deprecated resident-prefixed names, kept until the next major.
|
|
852
|
+
export type {
|
|
853
|
+
ResidentLearningEvidence,
|
|
854
|
+
ResidentSkillCandidate,
|
|
855
|
+
ResidentLearnedSkill,
|
|
856
|
+
ResidentLearningState,
|
|
857
|
+
ResidentProfileUpdate,
|
|
858
|
+
ResidentSkillEvaluation,
|
|
859
|
+
ResidentLearningProjectionOptions,
|
|
860
|
+
ResidentLearningSource,
|
|
861
|
+
ResidentLearningProjection,
|
|
862
|
+
ResidentLearningStage,
|
|
863
|
+
ResidentLearningReceipt,
|
|
864
|
+
ResidentLearningConsumption,
|
|
865
|
+
ResidentLearningCycleEvent,
|
|
866
|
+
ResidentLearningCycleContext,
|
|
867
|
+
ResidentLearningGenerationContext,
|
|
868
|
+
ResidentLearningExplorationContext,
|
|
869
|
+
ResidentLearningExploration,
|
|
870
|
+
ResidentLearningEvaluationContext,
|
|
871
|
+
ResidentLearningCycleOptions,
|
|
872
|
+
ResidentLearningCycleResult,
|
|
873
|
+
SqliteResidentLearningStoreOptions,
|
|
874
|
+
ResidentLearningArtifact,
|
|
875
|
+
ResidentLearningRecordedUsage,
|
|
876
|
+
ResidentLearningCycleSummary,
|
|
877
|
+
ResidentLearningDiscoveryOptions,
|
|
878
|
+
ResidentLearningDiscoveryResult,
|
|
879
|
+
ResidentLearningObservation,
|
|
880
|
+
ResidentLearningObservationRecord,
|
|
881
|
+
ResidentLearningTarget,
|
|
882
|
+
} from './learning/deprecated.js'
|
|
@@ -29,6 +29,13 @@ import {
|
|
|
29
29
|
*/
|
|
30
30
|
const MAX_RECEIPT_UNITS = 32_000
|
|
31
31
|
|
|
32
|
+
/** The heading of the file-evidence block; a later block under it replaces an earlier one. */
|
|
33
|
+
export const FILE_EVIDENCE_HEADING =
|
|
34
|
+
'Visible file evidence (as of this step; a later block with this heading replaces this one)'
|
|
35
|
+
|
|
36
|
+
/** Said when the entries of an earlier block no longer hold and none replaces them. */
|
|
37
|
+
export const FILE_EVIDENCE_NONE = `${FILE_EVIDENCE_HEADING}: no entry holds any longer.`
|
|
38
|
+
|
|
32
39
|
interface FileEvidence {
|
|
33
40
|
readonly path: string
|
|
34
41
|
/** Absent on the write-rooted entries; `'read'` on a body that is a receipt. */
|
|
@@ -79,7 +86,7 @@ export function describeVisibleFileEvidence(
|
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
88
|
if (files.size === 0) return
|
|
82
|
-
return
|
|
89
|
+
return `${FILE_EVIDENCE_HEADING}: each entry's current body is the complete body in the named successful write call, with the edit calls in editsInCalls — when present — applied in that order. An entry marked kind:"read" instead names a successful read call whose own receipt shows the file WHOLE, rendered with every line behind its own N<tab> prefix; that receipt is the body, and such an entry never carries editsInCalls. This runtime performed that reconstruction and checked it against its own file observation; it is not a derivation left to you. Reuse the body for a targeted edit; a read solely to recall it is unnecessary. This is NOT a fresh disk check, and after a resume the observation behind an entry may itself have been rebuilt from this conversation's own earlier calls rather than made while this process ran. Built-in edit/write still compare the disk body at mutation admission and refuse observed drift; on refusal inspect the current file and replan. Missing entries establish nothing.\n${JSON.stringify([...files.values()])}`
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
/** A full body that arrived whole in one call and is still the file's body. */
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
import { getTracer } from '../../../telemetry/runtime-accessors.js'
|
|
29
29
|
import { STRUCTURED_OUTPUT_TOOL_NAME } from '../../../tools/builtins/structuredOutput.js'
|
|
30
30
|
import type { ToolManager } from '../../../toolsets/manager.js'
|
|
31
|
+
import { splitAtEvidenceBlocks } from '../../../turn/evidence-recall.js'
|
|
31
32
|
import type { CostInfo, TokenUsage } from '../../../types/common/index.js'
|
|
32
33
|
import { NamzuError } from '../../../types/errors/index.js'
|
|
33
34
|
import type { MessageId, SessionId, TurnId } from '../../../types/ids/index.js'
|
|
@@ -57,6 +58,7 @@ import { createCallbackInference } from '../callback-inference.js'
|
|
|
57
58
|
import { SandboxAcquisitionStopped } from '../deferred-sandbox.js'
|
|
58
59
|
import { deliverDurableInbound } from '../durable-inbound.js'
|
|
59
60
|
import type { ToolCallOutcome } from '../executor.js'
|
|
61
|
+
import { FILE_EVIDENCE_NONE } from '../file-evidence-context.js'
|
|
60
62
|
import { projectObservationContext } from '../observation-context.js'
|
|
61
63
|
import { applyLifecycleHookResults } from '../plugin-hooks.js'
|
|
62
64
|
import {
|
|
@@ -102,14 +104,16 @@ import {
|
|
|
102
104
|
streamWithProviderRejectedImageRecovery,
|
|
103
105
|
} from './provider-rejected-image.js'
|
|
104
106
|
import { type MediaRemoval, RequestRepair } from './request-repair.js'
|
|
105
|
-
import {
|
|
107
|
+
import { TurnContextCarry } from './step-context.js'
|
|
106
108
|
import {
|
|
109
|
+
FILE_EVIDENCE_KEY,
|
|
107
110
|
type StepShaping,
|
|
108
111
|
appendWorkContext,
|
|
109
112
|
beforeStep,
|
|
110
113
|
prepareStep,
|
|
111
114
|
selectContextModel,
|
|
112
115
|
stepContextMessage,
|
|
116
|
+
workContextBlocks,
|
|
113
117
|
} from './step-shaping.js'
|
|
114
118
|
import { streamProviderTurn } from './stream-turn.js'
|
|
115
119
|
|
|
@@ -190,6 +194,8 @@ export class IterationOrchestrator {
|
|
|
190
194
|
* one process must not suppress each other's first envelope.
|
|
191
195
|
*/
|
|
192
196
|
private lastEnvelopeKey: string | undefined
|
|
197
|
+
/** Where this turn's request-only data first went, so it stays there. */
|
|
198
|
+
private readonly turnContext = new TurnContextCarry()
|
|
193
199
|
private previousRequestContext: RequestContextSnapshot | undefined
|
|
194
200
|
|
|
195
201
|
private projectObservations(messages: Message[]): Message[] {
|
|
@@ -895,27 +901,35 @@ export class IterationOrchestrator {
|
|
|
895
901
|
? [...workingMemory.history, createSystemMessage(stepPreamble)]
|
|
896
902
|
: [...workingMemory.history]
|
|
897
903
|
if (workingMemory.context) requestHistory.push(workingMemory.context)
|
|
898
|
-
// The blocks of data that belong to this turn (recalled memory and
|
|
899
|
-
// evidence, the context contributions) sit just before the
|
|
900
|
-
// operator's latest message, so the request is the last thing the
|
|
901
|
-
// model reads. The short reminders and notices stay after it.
|
|
902
|
-
placeBeforeLatestOperatorMessage(
|
|
903
|
-
requestHistory,
|
|
904
|
-
[contextText, step.context]
|
|
905
|
-
.filter((text): text is string => Boolean(text))
|
|
906
|
-
.map(stepContextMessage),
|
|
907
|
-
)
|
|
908
904
|
// After the history, never ahead of it: a system message in front
|
|
909
905
|
// of the conversation moves the prefix every cached request shares,
|
|
910
906
|
// and a mode change would re-key the whole conversation.
|
|
911
907
|
if (policyNotice) requestHistory.push(stepContextMessage(policyNotice))
|
|
912
|
-
const
|
|
908
|
+
const projected = projectRequestRichContent(
|
|
913
909
|
this.projectObservations(requestHistory),
|
|
914
910
|
this.ctx.turnConfig.maxRequestRichContentBytes ??
|
|
915
911
|
DEFAULT_MAX_REQUEST_RICH_CONTENT_BYTES,
|
|
916
912
|
{ imagesReadable: this.modelReadsImages(stepModel) },
|
|
917
913
|
)
|
|
918
|
-
|
|
914
|
+
// The blocks of data that belong to this turn (recalled memory and
|
|
915
|
+
// evidence, the context contributions, the work context) sit just
|
|
916
|
+
// before the operator's latest message the first time the model
|
|
917
|
+
// answers it, so the request is the last thing it reads. They stay
|
|
918
|
+
// there on every later call of the turn, and a block that first
|
|
919
|
+
// appears on a later call follows the history of that moment, so each
|
|
920
|
+
// request begins with the whole of the one before it. The short
|
|
921
|
+
// reminders and notices stay after the history.
|
|
922
|
+
const messages = [...projected]
|
|
923
|
+
this.turnContext.place(
|
|
924
|
+
messages,
|
|
925
|
+
requestHistory,
|
|
926
|
+
workingMemory.history.at(-1),
|
|
927
|
+
[contextText, ...(step.context ? splitAtEvidenceBlocks(step.context) : [])]
|
|
928
|
+
.filter((text): text is string => Boolean(text))
|
|
929
|
+
.map(stepContextMessage),
|
|
930
|
+
workContextBlocks(shaping, projected, iterationNum, step),
|
|
931
|
+
{ [FILE_EVIDENCE_KEY]: stepContextMessage(FILE_EVIDENCE_NONE) },
|
|
932
|
+
)
|
|
919
933
|
if (closingDirective) messages.push(closingDirective)
|
|
920
934
|
await this.reportUnsupportedToolResults(messages)
|
|
921
935
|
yield* this.ctx.drainPending()
|