@morning-start/dsh-code-toolkit 0.27.1 → 0.27.4
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 +56 -0
- package/index.js +8 -3
- package/package.json +1 -2
- package/src/command.js +59 -48
- package/src/i18n.js +4 -0
- package/src/identity.js +23 -0
- package/src/journal.js +10 -0
- package/src/runtime.js +21 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.27.4 — 2026-11-28
|
|
4
|
+
|
|
5
|
+
- **Fixed a corrupting write in `/code-caption` and `/pua`.** Both passed
|
|
6
|
+
`steer({ content, source })`, but the host's `Agent.steer` takes a complete
|
|
7
|
+
`UserMessage` and writes it into a `user/message` session event unchanged. The
|
|
8
|
+
partial message had no `id` and no `role`, so the session log failed validation
|
|
9
|
+
on the next load — the conversation became unopenable with
|
|
10
|
+
`session event at seq N lacks an identified message`. Both commands now build
|
|
11
|
+
the message with the same `userMessage()` every other delivery uses.
|
|
12
|
+
- Added a static guard to the suite: no `.steer({` / `.followup({` / `.inject({`
|
|
13
|
+
object literal may reach the host, both delivery paths must build through
|
|
14
|
+
`userMessage()`, and every built message is checked for a non-empty `id`,
|
|
15
|
+
`role: 'user'`, a `source.kind`, and a text block — the four fields the host's
|
|
16
|
+
session validator reads. Two messages never share an id.
|
|
17
|
+
- Verified end to end in an isolated instance with the host's own
|
|
18
|
+
`adoptSessionEvent` validator: `/code-caption` (44 events) and `/pua` (29
|
|
19
|
+
events) both pass with zero failures, after reproducing the original failure on
|
|
20
|
+
an affected log (`session event at seq 2182 lacks an identified message`).
|
|
21
|
+
- 95 → 96 deterministic checks.
|
|
22
|
+
|
|
23
|
+
## 0.27.3 — 2026-11-28
|
|
24
|
+
|
|
25
|
+
- Normalised the bundle manifest to the fields the host actually reads. Removed
|
|
26
|
+
`dsh.manifestVersion`, which no part of the Loader or Plugin Manager looks at;
|
|
27
|
+
the `dsh` block now holds only `bundle.patch`. `engines.dsh` and the exported
|
|
28
|
+
`name` were confirmed as recognised fields and left as they are.
|
|
29
|
+
- Normalised `market.json` to a marketplace draft: dropped the author `_note`,
|
|
30
|
+
added both-language `title` and `description`, and `keywords` for search.
|
|
31
|
+
- `Config` stays undeclared: the standard marks it optional, and the plugin
|
|
32
|
+
validates its config in `apply()` with translated errors. Schemastery — the
|
|
33
|
+
library behind the `~standard` interface — is host-bundled and a `link:`-
|
|
34
|
+
installed plugin cannot resolve it, so a hand-rolled schema would only add
|
|
35
|
+
code that the host never calls.
|
|
36
|
+
- 93 → 95 deterministic checks.
|
|
37
|
+
|
|
38
|
+
## 0.27.2 — 2026-11-27
|
|
39
|
+
|
|
40
|
+
- One identity rule for every piece of per-session state. The shell resolved
|
|
41
|
+
`agent.session?.id ?? agent.id` in four places, and the single-flight slot took
|
|
42
|
+
`agent.id` while the journal took the session id: when those two differed,
|
|
43
|
+
`/code-cancel` and `/code-status` looked under a key the run never wrote to.
|
|
44
|
+
`src/identity.js` now owns the rule — the session id wins, the agent id
|
|
45
|
+
falls back — and the slot, the journal record and the local commands all key
|
|
46
|
+
through it.
|
|
47
|
+
- An isolated run with no usable identity is refused with a clear error instead
|
|
48
|
+
of registering under `undefined`, where every unidentified session would have
|
|
49
|
+
crowded into one slot. An inline run with no identity still proceeds: it takes
|
|
50
|
+
no slot, only the journal record is skipped.
|
|
51
|
+
- The child persona check no longer has a race. The `agent/created` listener
|
|
52
|
+
now stays up until the run is over, because the child can be created after
|
|
53
|
+
`startActivation` resolves; and a run that never saw the child fails loudly
|
|
54
|
+
instead of reporting a persona-less result as a good report.
|
|
55
|
+
- `Journal.path` rejects a missing or non-string id rather than coercing it, so
|
|
56
|
+
an unidentified session can never land in one shared file.
|
|
57
|
+
- 88 → 93 deterministic checks.
|
|
58
|
+
|
|
3
59
|
## 0.27.1 — 2026-11-26
|
|
4
60
|
|
|
5
61
|
- The plugin detail page now falls back to the README. The host renders a detail
|
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { dirname, isAbsolute, join } from 'node:path'
|
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
4
|
|
|
5
5
|
import { outputLanguage, readHostLocale, resolveLocale, translate } from './src/i18n.js'
|
|
6
|
+
import { sessionKey } from './src/identity.js'
|
|
6
7
|
import { Journal } from './src/journal.js'
|
|
7
8
|
import { parseReport, renderReport } from './src/report.js'
|
|
8
9
|
import { buildPua, flavorList, resolveFlavor } from './src/pua.js'
|
|
@@ -178,10 +179,13 @@ export function apply(ctx, config = {}) {
|
|
|
178
179
|
kind: 'local',
|
|
179
180
|
descriptionKey: 'cmd.status',
|
|
180
181
|
run: async ({ agent, t, host: h }) => {
|
|
181
|
-
|
|
182
|
+
// One identity for both the running slot and the journal record, so the
|
|
183
|
+
// status shown matches the key the run actually registered under.
|
|
184
|
+
const key = sessionKey(agent)
|
|
185
|
+
const entry = key ? h.running.get(key) : undefined
|
|
182
186
|
if (entry) return { kind: 'success', text: `${t('status.running')}${entry.label}` }
|
|
183
187
|
|
|
184
|
-
const record = await h.journal.read(
|
|
188
|
+
const record = key ? await h.journal.read(key).catch(() => undefined) : undefined
|
|
185
189
|
if (!record) return { kind: 'success', text: t('status.none') }
|
|
186
190
|
if (record.state === 'running') return { kind: 'success', text: t('status.interrupted') }
|
|
187
191
|
if (record.state === 'submitted') {
|
|
@@ -195,7 +199,8 @@ export function apply(ctx, config = {}) {
|
|
|
195
199
|
kind: 'local',
|
|
196
200
|
descriptionKey: 'cmd.cancel',
|
|
197
201
|
run: ({ agent, t, host: h }) => {
|
|
198
|
-
const
|
|
202
|
+
const key = sessionKey(agent)
|
|
203
|
+
const entry = key ? h.running.get(key) : undefined
|
|
199
204
|
if (!entry) return { kind: 'success', text: t('cancel.none') }
|
|
200
205
|
entry.controller.abort()
|
|
201
206
|
return { kind: 'success', text: t('cancel.done') }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morning-start/dsh-code-toolkit",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"dsh": ">=0.2.2-rc.1 <0.3.0-0"
|
|
53
53
|
},
|
|
54
54
|
"dsh": {
|
|
55
|
-
"manifestVersion": 1,
|
|
56
55
|
"bundle": {
|
|
57
56
|
"patch": "./cordis.patch.yml"
|
|
58
57
|
}
|
package/src/command.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolveScope, scopeHasChanges, scopeInstruction, scopeLabel, selectScope, splitFlags } from './selection.js'
|
|
2
2
|
import { failureMessage, reportMessage, userMessage, SOURCE_KIND } from './delivery.js'
|
|
3
3
|
import { outputLanguage } from './i18n.js'
|
|
4
|
+
import { sessionKey } from './identity.js'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The receipt names where the task went and what it will do: the current
|
|
@@ -70,25 +71,25 @@ export class SessionCommand {
|
|
|
70
71
|
|
|
71
72
|
// A protocol is long; injecting it twice in one session doubles the context
|
|
72
73
|
// and gives the agent two copies to disagree with. Only the task is new.
|
|
73
|
-
const sessionId = agent
|
|
74
|
-
const previous = await host.journal.read(sessionId).catch(() => undefined)
|
|
74
|
+
const sessionId = sessionKey(agent)
|
|
75
|
+
const previous = sessionId ? await host.journal.read(sessionId).catch(() => undefined) : undefined
|
|
75
76
|
const installed = previous?.command === spec.command && previous?.state === 'installed'
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
78
|
+
// `steer` takes a complete UserMessage, not a partial `{ content, source }`:
|
|
79
|
+
// the host writes the message into a `user/message` session event as-is, and
|
|
80
|
+
// a message without its own `id` and `role` fails session-log validation on
|
|
81
|
+
// the next load. Build it the same way every other delivery does.
|
|
82
|
+
await agent.steer(userMessage(spec.buildText({ rawInput, agent, locale, host, installed })))
|
|
83
|
+
|
|
84
|
+
if (sessionId) {
|
|
85
|
+
await host.journal
|
|
86
|
+
.write(sessionId, {
|
|
87
|
+
state: 'installed',
|
|
88
|
+
command: spec.command,
|
|
89
|
+
at: new Date().toISOString(),
|
|
90
|
+
})
|
|
91
|
+
.catch(() => undefined)
|
|
92
|
+
}
|
|
92
93
|
|
|
93
94
|
return {
|
|
94
95
|
kind: 'success',
|
|
@@ -111,7 +112,7 @@ export class SessionCommand {
|
|
|
111
112
|
const { host } = this
|
|
112
113
|
const controller = new AbortController()
|
|
113
114
|
const combined = AbortSignal.any([signal, controller.signal])
|
|
114
|
-
const sessionId = agent
|
|
115
|
+
const sessionId = sessionKey(agent)
|
|
115
116
|
const language = outputLanguage(locale)
|
|
116
117
|
const chinese = String(locale).startsWith('zh')
|
|
117
118
|
|
|
@@ -134,7 +135,12 @@ export class SessionCommand {
|
|
|
134
135
|
/** Run the isolated agent and deliver its report as a message. */
|
|
135
136
|
startIsolated(agent, rawInput, signal, locale, t, report) {
|
|
136
137
|
const { host, spec } = this
|
|
137
|
-
|
|
138
|
+
// The single-flight slot and the journal record are keyed by the same
|
|
139
|
+
// identity: one key per session, so cancellation and status find the run
|
|
140
|
+
// that registered it. Without one there is nothing to key on, and inventing
|
|
141
|
+
// a shared key would let every unidentified session crowd into one slot.
|
|
142
|
+
const key = sessionKey(agent)
|
|
143
|
+
if (!key) return { kind: 'error', text: t('error.noIdentity') }
|
|
138
144
|
const stale = host.running.get(key)
|
|
139
145
|
// A run can hang on something outside its own control — an approval nobody
|
|
140
146
|
// answers, a child that never reports. Past the limit the slot is released
|
|
@@ -150,7 +156,9 @@ export class SessionCommand {
|
|
|
150
156
|
const controller = new AbortController()
|
|
151
157
|
const combined = AbortSignal.any([signal, controller.signal])
|
|
152
158
|
host.running.set(key, { controller, label: host.translate(locale, spec.descriptionKey), startedAt: Date.now() })
|
|
153
|
-
|
|
159
|
+
// The journal record is keyed by the same identity as the slot: one key per
|
|
160
|
+
// session, so a status read and a cancellation both find what the run wrote.
|
|
161
|
+
const sessionId = key
|
|
154
162
|
const language = outputLanguage(locale)
|
|
155
163
|
const chinese = String(locale).startsWith('zh')
|
|
156
164
|
// The receipt is resolved before the child starts, so it can name the scope
|
|
@@ -223,20 +231,27 @@ export class SessionCommand {
|
|
|
223
231
|
return { scope, mode, prompt, receipt }
|
|
224
232
|
}
|
|
225
233
|
|
|
234
|
+
/**
|
|
235
|
+
* Write one journal record. A run with no usable identity has no record to
|
|
236
|
+
* write — the task still runs, but nothing to key it to is recorded.
|
|
237
|
+
*/
|
|
238
|
+
async record(host, sessionId, record) {
|
|
239
|
+
if (!sessionId) return
|
|
240
|
+
await host.journal.write(sessionId, record).catch(() => undefined)
|
|
241
|
+
}
|
|
242
|
+
|
|
226
243
|
/** Resolve the scope and assemble the task text (shared by both paths). */
|
|
227
244
|
async prepare(agent, rawInput, combined, locale, t, sessionId, report) {
|
|
228
245
|
const { host, spec } = this
|
|
229
246
|
const { scope, mode, prompt } = await this.resolveTask(agent, rawInput, combined, locale, t, sessionId, report, true)
|
|
230
247
|
|
|
231
|
-
await host
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
})
|
|
239
|
-
.catch(() => undefined)
|
|
248
|
+
await this.record(host, sessionId, {
|
|
249
|
+
state: 'submitted',
|
|
250
|
+
command: spec.command,
|
|
251
|
+
scope: scopeLabel(scope),
|
|
252
|
+
mode,
|
|
253
|
+
at: new Date().toISOString(),
|
|
254
|
+
})
|
|
240
255
|
|
|
241
256
|
return prompt
|
|
242
257
|
}
|
|
@@ -245,15 +260,13 @@ export class SessionCommand {
|
|
|
245
260
|
async execute(agent, { scope, mode, prompt }, combined, locale, t, sessionId) {
|
|
246
261
|
const { host, spec } = this
|
|
247
262
|
|
|
248
|
-
await host
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
})
|
|
256
|
-
.catch(() => undefined)
|
|
263
|
+
await this.record(host, sessionId, {
|
|
264
|
+
state: 'running',
|
|
265
|
+
command: spec.command,
|
|
266
|
+
scope: scopeLabel(scope),
|
|
267
|
+
mode,
|
|
268
|
+
at: new Date().toISOString(),
|
|
269
|
+
})
|
|
257
270
|
|
|
258
271
|
const raw = await host.runIsolatedAgent(agent, {
|
|
259
272
|
persona: `${spec.persona.text}\n\n${outputLanguage(locale)}`,
|
|
@@ -267,16 +280,14 @@ export class SessionCommand {
|
|
|
267
280
|
const body = spec.structured ? host.renderReport(host.parseReport(raw), t) : raw
|
|
268
281
|
const text = [`> ${scopeLabel(scope)} · ${mode}`, '', body].join('\n')
|
|
269
282
|
|
|
270
|
-
await host
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
})
|
|
279
|
-
.catch(() => undefined)
|
|
283
|
+
await this.record(host, sessionId, {
|
|
284
|
+
state: 'finished',
|
|
285
|
+
command: spec.command,
|
|
286
|
+
scope: scopeLabel(scope),
|
|
287
|
+
mode,
|
|
288
|
+
result: text,
|
|
289
|
+
at: new Date().toISOString(),
|
|
290
|
+
})
|
|
280
291
|
|
|
281
292
|
return text
|
|
282
293
|
}
|
package/src/i18n.js
CHANGED
|
@@ -44,11 +44,13 @@ const MESSAGES = {
|
|
|
44
44
|
'hint.scrub': '留空即整个项目;或 --files a.js,.env / 自定义说明;加 sub 用子 agent,加 report 只出报告',
|
|
45
45
|
'hint.review': '留空即审未提交的改动(都提交了就审分支相对基线);或 --files / --branch <对比分支> / --commit <sha>;默认出报告并修复,加 report 只出报告,加 sub 用子 agent',
|
|
46
46
|
'error.noCwd': '当前会话没有工作目录。',
|
|
47
|
+
'error.noIdentity': '当前会话没有可用的会话标识,无法记录任务状态或做单飞保护。',
|
|
47
48
|
'error.noProvider': '当前宿主缺少独立上下文的原生 spawn provider,无法运行独立 agent。',
|
|
48
49
|
'error.noActivation': '当前宿主缺少原生子 agent 启动接口,请升级 DeepSeek Harness。',
|
|
49
50
|
'error.noGit': '不是 Git 仓库,或 git 不可用:',
|
|
50
51
|
'error.aborted': '操作已取消。',
|
|
51
52
|
'error.noResult': '子 agent 没有返回报告。',
|
|
53
|
+
'error.noPersona': '子 agent 没有收到 persona,运行结果不可信。',
|
|
52
54
|
'error.busy': '当前会话已有代码工具箱任务在运行,请等待或先取消。',
|
|
53
55
|
'error.noScope': '没有选中有效范围。',
|
|
54
56
|
'error.emptyScope': '没有可审查的改动:当前分支与基线一致,工作区也是干净的。试试 --branch <别的分支>、--commit <sha> 或 --files <路径>。',
|
|
@@ -97,11 +99,13 @@ const MESSAGES = {
|
|
|
97
99
|
'hint.scrub': 'Leave empty for the whole project; or --files a.js,.env / custom instructions; add sub for a subagent, report for a plan only',
|
|
98
100
|
'hint.review': 'Leave empty to review the uncommitted work (or the branch against its base when clean); or --files / --branch <ref> / --commit <sha>; fixes what it finds by default — add report for the report only, sub for a subagent',
|
|
99
101
|
'error.noCwd': 'This session has no working directory.',
|
|
102
|
+
'error.noIdentity': 'This session has no usable session id, so task state cannot be recorded or guarded.',
|
|
100
103
|
'error.noProvider': 'This host has no independent-context native spawn provider, so no isolated agent can run.',
|
|
101
104
|
'error.noActivation': 'This host has no native subagent activation API; upgrade DeepSeek Harness.',
|
|
102
105
|
'error.noGit': 'Not a Git repository, or git is unavailable: ',
|
|
103
106
|
'error.aborted': 'Cancelled.',
|
|
104
107
|
'error.noResult': 'The subagent returned no report.',
|
|
108
|
+
'error.noPersona': 'The subagent never received its persona, so its result cannot be trusted.',
|
|
105
109
|
'error.busy': 'A code-toolkit task is already running in this session; wait or cancel it first.',
|
|
106
110
|
'error.noScope': 'No valid scope was selected.',
|
|
107
111
|
'error.emptyScope': 'Nothing to review: the branch matches its base and the working tree is clean. Try --branch <another branch>, --commit <sha>, or --files <path>.',
|
package/src/identity.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one identifier a command's state is keyed by.
|
|
3
|
+
*
|
|
4
|
+
* Every piece of per-session state — the journal record, the single-flight slot,
|
|
5
|
+
* the cancellation handle — has to be found again from the same place, so there
|
|
6
|
+
* is exactly one rule for which id that is. The shell used to resolve it four
|
|
7
|
+
* times as `agent.session?.id ?? agent.id`, and the single-flight slot took
|
|
8
|
+
* `agent.id` while the journal took the session id: a session whose two ids
|
|
9
|
+
* differ would have split one run's state across two keys, so `/code-cancel`
|
|
10
|
+
* and `/code-status` would look in the place the run never wrote to.
|
|
11
|
+
*
|
|
12
|
+
* The session id wins because that is the identity the journal already names
|
|
13
|
+
* its records after; `agent.id` is the fallback for a host that gives an agent
|
|
14
|
+
* without a session. When neither is a usable string the state cannot be keyed
|
|
15
|
+
* at all, and the caller decides what that means rather than inventing a key.
|
|
16
|
+
*/
|
|
17
|
+
export function sessionKey(agent) {
|
|
18
|
+
const candidates = [agent?.session?.id, agent?.id]
|
|
19
|
+
for (const candidate of candidates) {
|
|
20
|
+
if (typeof candidate === 'string' && candidate.trim()) return candidate
|
|
21
|
+
}
|
|
22
|
+
return undefined
|
|
23
|
+
}
|
package/src/journal.js
CHANGED
|
@@ -20,7 +20,17 @@ export class Journal {
|
|
|
20
20
|
return join(home, 'code-toolkit')
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* The file one session's record lives in, named after a hash of its id.
|
|
25
|
+
*
|
|
26
|
+
* A missing or non-string id throws rather than being coerced: `createHash`
|
|
27
|
+
* rejects a non-string argument, and silently hashing `undefined` would put
|
|
28
|
+
* every unidentified session into one shared file.
|
|
29
|
+
*/
|
|
23
30
|
path(sessionId) {
|
|
31
|
+
if (typeof sessionId !== 'string' || !sessionId.trim()) {
|
|
32
|
+
throw new Error('Journal.path needs a session id')
|
|
33
|
+
}
|
|
24
34
|
return join(this.directory, `${createHash('sha256').update(sessionId).digest('hex')}.json`)
|
|
25
35
|
}
|
|
26
36
|
|
package/src/runtime.js
CHANGED
|
@@ -23,6 +23,13 @@ const DELEGATE_TOOLS = [
|
|
|
23
23
|
* Requires the native `spawn` provider, whose `inheritsParentContext` is false:
|
|
24
24
|
* the child must read the code itself instead of inheriting this conversation.
|
|
25
25
|
* Without that, a review only sees what the main agent already believes.
|
|
26
|
+
*
|
|
27
|
+
* The persona is attached from an `agent/created` listener keyed on the child id
|
|
28
|
+
* the plugin hands the host. The listener stays up until the run is over, because
|
|
29
|
+
* the child may be created after `startActivation` resolves; if it were removed
|
|
30
|
+
* the moment the activation settled, the persona would silently never attach.
|
|
31
|
+
* When the run finishes without the listener ever firing, the child ran without
|
|
32
|
+
* a persona — which is exactly the silent failure this function refuses to allow.
|
|
26
33
|
*/
|
|
27
34
|
export async function runIsolatedAgent(ctx, parent, options) {
|
|
28
35
|
const { persona, prompt, label, signal, model, t } = options
|
|
@@ -38,9 +45,10 @@ export async function runIsolatedAgent(ctx, parent, options) {
|
|
|
38
45
|
const childId = randomUUID()
|
|
39
46
|
const deny = DELEGATE_TOOLS.filter((name) => ctx.tools.get(name, parent) !== undefined)
|
|
40
47
|
|
|
41
|
-
let
|
|
48
|
+
let injected = false
|
|
42
49
|
const stopWatching = ctx.on('agent/created', ({ agent }) => {
|
|
43
50
|
if (agent.id !== childId) return
|
|
51
|
+
injected = true
|
|
44
52
|
agent.ctx.systemPrompt.section({
|
|
45
53
|
name: PERSONA_SECTION,
|
|
46
54
|
order: agent.ctx.systemPrompt.getSectionOrder(PERSONA_SECTION),
|
|
@@ -49,6 +57,7 @@ export async function runIsolatedAgent(ctx, parent, options) {
|
|
|
49
57
|
if (deny.length) agent.ctx.tools.restrict({ deny })
|
|
50
58
|
})
|
|
51
59
|
|
|
60
|
+
let activation
|
|
52
61
|
try {
|
|
53
62
|
// 0.2.2-rc.1 takes a nested `request`; rc.2+ takes a flat spec and exposes
|
|
54
63
|
// `rootOf`. Keep both so the declared engine range stays honest.
|
|
@@ -66,11 +75,7 @@ export async function runIsolatedAgent(ctx, parent, options) {
|
|
|
66
75
|
delivery: 'caller',
|
|
67
76
|
...(flat ? request : { request }),
|
|
68
77
|
})
|
|
69
|
-
} finally {
|
|
70
|
-
stopWatching()
|
|
71
|
-
}
|
|
72
78
|
|
|
73
|
-
try {
|
|
74
79
|
const result = await activation.result
|
|
75
80
|
if (signal.aborted) throw Object.assign(new Error('aborted'), { name: 'AbortError' })
|
|
76
81
|
if (result.stopReason !== 'completed') {
|
|
@@ -83,12 +88,19 @@ export async function runIsolatedAgent(ctx, parent, options) {
|
|
|
83
88
|
.join('')
|
|
84
89
|
.trim()
|
|
85
90
|
if (!text) throw new Error(t('error.noResult'))
|
|
91
|
+
// The child may finish before its own creation event reaches this listener.
|
|
92
|
+
// A run that never saw the child is one that ran without the persona, which
|
|
93
|
+
// is a silent failure worth failing loudly instead of reporting as a report.
|
|
94
|
+
if (!injected) throw new Error(t('error.noPersona'))
|
|
86
95
|
return text
|
|
87
96
|
} finally {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
97
|
+
stopWatching()
|
|
98
|
+
if (activation) {
|
|
99
|
+
try {
|
|
100
|
+
await activation.dispose()
|
|
101
|
+
} catch {
|
|
102
|
+
/* the session may already be gone */
|
|
103
|
+
}
|
|
92
104
|
}
|
|
93
105
|
}
|
|
94
106
|
}
|