opencode-subagent-tools 0.1.0 → 0.2.1

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.
@@ -0,0 +1,602 @@
1
+ import { normalizeSessionID } from "./session";
2
+ import { RUN_STATUS, type RunStatus } from "./status";
3
+ import { isUnsafeControlCode } from "./text";
4
+
5
+ export const BACKGROUND_JOB_KIND = {
6
+ shell: "shell",
7
+ image: "image",
8
+ subagent: "subagent",
9
+ codemode: "codemode",
10
+ } as const;
11
+
12
+ export type BackgroundJobKind =
13
+ (typeof BACKGROUND_JOB_KIND)[keyof typeof BACKGROUND_JOB_KIND];
14
+
15
+ export const BACKGROUND_JOB_KINDS: readonly BackgroundJobKind[] =
16
+ Object.values(BACKGROUND_JOB_KIND);
17
+
18
+ const BACKGROUND_JOB_KIND_SET: ReadonlySet<string> = new Set(BACKGROUND_JOB_KINDS);
19
+
20
+ const isBackgroundJobKind = (value: unknown): value is BackgroundJobKind =>
21
+ typeof value === "string" && BACKGROUND_JOB_KIND_SET.has(value);
22
+
23
+ export interface BackgroundJobInfo {
24
+ kinds: BackgroundJobKind[];
25
+ mayRemain?: boolean;
26
+ stateUnknown?: boolean;
27
+ }
28
+
29
+ export const BACKGROUND_JOB_SCHEMA = {
30
+ type: "object",
31
+ properties: {
32
+ kinds: {
33
+ type: "array",
34
+ items: { type: "string", enum: [...BACKGROUND_JOB_KINDS] },
35
+ },
36
+ mayRemain: { type: "boolean" },
37
+ stateUnknown: { type: "boolean" },
38
+ },
39
+ required: ["kinds"],
40
+ additionalProperties: false,
41
+ } as const;
42
+
43
+ export const backgroundJobLabel = (job: BackgroundJobInfo): string => {
44
+ const kinds = job.kinds.join(",");
45
+ if (job.stateUnknown) return kinds ? `${kinds},?` : "unknown";
46
+ return kinds || "unknown";
47
+ };
48
+
49
+ /** Own activity: running, unknown, or any observed background work. */
50
+ export const isSessionActive = (
51
+ status: RunStatus | undefined,
52
+ backgroundJob: BackgroundJobInfo | undefined,
53
+ ): boolean =>
54
+ status === undefined ||
55
+ status === RUN_STATUS.running ||
56
+ status === RUN_STATUS.unknown ||
57
+ backgroundJob !== undefined;
58
+
59
+ export const MAX_BACKGROUND_SESSIONS = 500;
60
+ export const MAX_BACKGROUND_JOBS_PER_KIND = 100;
61
+ export const MAX_BACKGROUND_KEY_LENGTH = 500;
62
+
63
+ /** Validate a shell/image key without rejecting spaces in image paths. */
64
+ export const normalizeBackgroundKey = (value: unknown): string | undefined => {
65
+ if (typeof value !== "string") return undefined;
66
+ const key = value.trim();
67
+ if (key.length === 0 || key.length > MAX_BACKGROUND_KEY_LENGTH) return undefined;
68
+ const unsafe = Array.from(key).some((char) => {
69
+ const code = char.codePointAt(0) ?? 0;
70
+ return isUnsafeControlCode(code);
71
+ });
72
+ return unsafe ? undefined : key;
73
+ };
74
+
75
+ interface BackgroundState {
76
+ shell: Map<string, number>;
77
+ image: Map<string, number>;
78
+ subagent: Map<string, number>;
79
+ codemode: Map<string, number>;
80
+ /** Last idle snapshot applied for this session, trusted or not. */
81
+ snapshotAt: number;
82
+ /** Whether an idle snapshot has ever been authoritative for this session. */
83
+ hasAuthoritativeSnapshot: boolean;
84
+ /** Descendant owners named by the last idle snapshot. */
85
+ snapshotOwners: Set<string>;
86
+ /** Evidence that background work remains but its kind is unknown. */
87
+ unknownAt: number;
88
+ }
89
+
90
+ const createState = (): BackgroundState => ({
91
+ shell: new Map(),
92
+ image: new Map(),
93
+ subagent: new Map(),
94
+ codemode: new Map(),
95
+ snapshotAt: 0,
96
+ hasAuthoritativeSnapshot: false,
97
+ snapshotOwners: new Set(),
98
+ unknownAt: 0,
99
+ });
100
+
101
+ const stateJobMap = (
102
+ state: BackgroundState,
103
+ kind: BackgroundJobKind,
104
+ ): Map<string, number> => state[kind];
105
+
106
+ const trimMap = (map: Map<string, number>, limit: number) => {
107
+ while (map.size > limit) {
108
+ const oldest = map.keys().next().value;
109
+ if (oldest === undefined) break;
110
+ map.delete(oldest);
111
+ }
112
+ };
113
+
114
+ const trimSet = (set: Set<string>, limit: number) => {
115
+ while (set.size > limit) {
116
+ const oldest = set.values().next().value;
117
+ if (oldest === undefined) break;
118
+ set.delete(oldest);
119
+ }
120
+ };
121
+
122
+ const clearAtOrBefore = (state: BackgroundState, at: number) => {
123
+ for (const kind of BACKGROUND_JOB_KINDS) {
124
+ const map = stateJobMap(state, kind);
125
+ for (const [key, startedAt] of map) {
126
+ if (startedAt <= at) map.delete(key);
127
+ }
128
+ }
129
+ if (state.unknownAt > 0 && state.unknownAt <= at) state.unknownAt = 0;
130
+ };
131
+
132
+ const addJob = (
133
+ state: BackgroundState,
134
+ kind: BackgroundJobKind,
135
+ key: string,
136
+ at: number,
137
+ ) => {
138
+ const map = stateJobMap(state, kind);
139
+ const existing = map.get(key);
140
+ if (existing !== undefined && existing > at) return;
141
+ map.delete(key);
142
+ map.set(key, at);
143
+ trimMap(map, MAX_BACKGROUND_JOBS_PER_KIND);
144
+ };
145
+
146
+ const removeJob = (
147
+ state: BackgroundState,
148
+ kind: BackgroundJobKind,
149
+ key: string,
150
+ at: number,
151
+ ) => {
152
+ const map = stateJobMap(state, kind);
153
+ const existing = map.get(key);
154
+ if (existing === undefined || at < existing) return;
155
+ map.delete(key);
156
+ };
157
+
158
+ const markUnknown = (state: BackgroundState, at: number) => {
159
+ state.unknownAt = Math.max(state.unknownAt, at);
160
+ };
161
+
162
+ interface ParsedIdleItem {
163
+ kind: BackgroundJobKind;
164
+ key: string;
165
+ owner: string;
166
+ }
167
+
168
+ type IdleItemParse = { ok: true; item: ParsedIdleItem } | { ok: false; owner?: string };
169
+
170
+ const parseIdleItem = (value: unknown): IdleItemParse => {
171
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
172
+ return { ok: false };
173
+ }
174
+ const item = value as Record<string, unknown>;
175
+ const owner = normalizeSessionID(item.sessionID);
176
+ if (!isBackgroundJobKind(item.kind)) {
177
+ return owner ? { ok: false, owner } : { ok: false };
178
+ }
179
+ if (!owner) return { ok: false };
180
+
181
+ if (item.kind === BACKGROUND_JOB_KIND.shell) {
182
+ const key = normalizeBackgroundKey(item.shellID);
183
+ return key
184
+ ? { ok: true, item: { kind: item.kind, key, owner } }
185
+ : { ok: false, owner };
186
+ }
187
+ if (item.kind === BACKGROUND_JOB_KIND.image) {
188
+ const key = normalizeBackgroundKey(item.path) ?? normalizeBackgroundKey(item.model);
189
+ return key
190
+ ? { ok: true, item: { kind: item.kind, key, owner } }
191
+ : { ok: false, owner };
192
+ }
193
+ if (item.kind === BACKGROUND_JOB_KIND.codemode) {
194
+ const key = normalizeBackgroundKey(item.jobID);
195
+ return key
196
+ ? { ok: true, item: { kind: item.kind, key, owner } }
197
+ : { ok: false, owner };
198
+ }
199
+ const key = normalizeSessionID(item.childSessionID);
200
+ return key ? { ok: true, item: { kind: item.kind, key, owner } } : { ok: false, owner };
201
+ };
202
+
203
+ export interface BackgroundContextSession {
204
+ context: (
205
+ input: { sessionID: string },
206
+ options?: { signal?: AbortSignal },
207
+ ) => Promise<unknown>;
208
+ }
209
+
210
+ export interface BackgroundProbeInput {
211
+ session: BackgroundContextSession;
212
+ targetID: string;
213
+ signal?: AbortSignal;
214
+ }
215
+
216
+ export interface BackgroundProbeResult {
217
+ backgroundJob?: BackgroundJobInfo;
218
+ subtreeActive: boolean;
219
+ failed: boolean;
220
+ }
221
+
222
+ interface ProbeToolPart {
223
+ type?: unknown;
224
+ name?: unknown;
225
+ state?: { status?: unknown };
226
+ }
227
+
228
+ interface ProbeMessage {
229
+ type?: unknown;
230
+ status?: unknown;
231
+ content?: unknown;
232
+ }
233
+
234
+ interface ContextRead {
235
+ messages: ProbeMessage[];
236
+ failed: boolean;
237
+ }
238
+
239
+ const readContext = async (
240
+ session: BackgroundContextSession,
241
+ sessionID: string,
242
+ signal?: AbortSignal,
243
+ ): Promise<ContextRead> => {
244
+ try {
245
+ const result = await session.context({ sessionID }, { signal });
246
+ if (!Array.isArray(result)) return { messages: [], failed: true };
247
+ const messages: ProbeMessage[] = [];
248
+ let failed = false;
249
+ for (const item of result) {
250
+ if (!item || typeof item !== "object" || Array.isArray(item)) {
251
+ failed = true;
252
+ continue;
253
+ }
254
+ messages.push(item as ProbeMessage);
255
+ }
256
+ return { messages, failed };
257
+ } catch {
258
+ return { messages: [], failed: true };
259
+ }
260
+ };
261
+
262
+ /** Tool names whose running call proves the session owns that background kind. */
263
+ const RUNNING_TOOL_KIND: ReadonlyMap<string, BackgroundJobKind> = new Map([
264
+ ["shell", BACKGROUND_JOB_KIND.shell],
265
+ ["image", BACKGROUND_JOB_KIND.image],
266
+ ["subagent", BACKGROUND_JOB_KIND.subagent],
267
+ ]);
268
+
269
+ const scanTargetMessages = (
270
+ messages: readonly ProbeMessage[],
271
+ kinds: Set<BackgroundJobKind>,
272
+ ) => {
273
+ for (const message of messages) {
274
+ if (message.type === "shell" && message.status === "running") {
275
+ kinds.add(BACKGROUND_JOB_KIND.shell);
276
+ }
277
+ if (message.type !== "assistant" || !Array.isArray(message.content)) continue;
278
+ for (const raw of message.content) {
279
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
280
+ const part = raw as ProbeToolPart;
281
+ if (part.type !== "tool" || part.state?.status !== "running") continue;
282
+ const kind =
283
+ typeof part.name === "string" ? RUNNING_TOOL_KIND.get(part.name) : undefined;
284
+ if (kind) kinds.add(kind);
285
+ }
286
+ }
287
+ };
288
+
289
+ export const createBackgroundJobStore = () => {
290
+ const states = new Map<string, BackgroundState>();
291
+ const deletedAt = new Map<string, number>();
292
+
293
+ const stateFor = (sessionID: string): BackgroundState => {
294
+ const existing = states.get(sessionID);
295
+ if (existing) {
296
+ // Keep Map iteration order least-recently-used first.
297
+ states.delete(sessionID);
298
+ states.set(sessionID, existing);
299
+ return existing;
300
+ }
301
+ const state = createState();
302
+ states.set(sessionID, state);
303
+ while (states.size > MAX_BACKGROUND_SESSIONS) {
304
+ const oldest = states.keys().next().value;
305
+ if (oldest === undefined) break;
306
+ states.delete(oldest);
307
+ }
308
+ return state;
309
+ };
310
+
311
+ const isDeletedAtOrAfter = (sessionID: string, at: number): boolean =>
312
+ at <= (deletedAt.get(sessionID) ?? 0);
313
+
314
+ const rememberDeleted = (sessionID: string, at: number) => {
315
+ const previous = deletedAt.get(sessionID) ?? 0;
316
+ if (at < previous) return;
317
+ deletedAt.delete(sessionID);
318
+ deletedAt.set(sessionID, at);
319
+ trimMap(deletedAt, MAX_BACKGROUND_SESSIONS);
320
+ };
321
+
322
+ const recordShellStarted = (sessionID: string, shellID: unknown, at: number) => {
323
+ const id = normalizeSessionID(sessionID);
324
+ const key = normalizeBackgroundKey(shellID);
325
+ if (!id || !key || isDeletedAtOrAfter(id, at)) return;
326
+ const state = stateFor(id);
327
+ if (at < state.snapshotAt) return;
328
+ addJob(state, BACKGROUND_JOB_KIND.shell, key, at);
329
+ };
330
+
331
+ const recordShellEnded = (sessionID: string, shellID: unknown, at: number) => {
332
+ const id = normalizeSessionID(sessionID);
333
+ const key = normalizeBackgroundKey(shellID);
334
+ if (!id || !key || isDeletedAtOrAfter(id, at)) return;
335
+ const state = states.get(id);
336
+ if (!state || at < state.snapshotAt) return;
337
+ removeJob(state, BACKGROUND_JOB_KIND.shell, key, at);
338
+ };
339
+
340
+ /**
341
+ * Apply an `experimental.idle` snapshot. The hook lists work owned by the
342
+ * idle session and its descendants; items are stored under their owner so a
343
+ * descendant's job never makes the idle parent active. Code Mode scripts are
344
+ * reported only through this hook; shell events do not cover them.
345
+ *
346
+ * The snapshot is authoritative only when every item can be parsed. An item
347
+ * with a known owner preserves that owner's jobs and marks its state unknown;
348
+ * an item with no usable owner preserves every known job, because its owner
349
+ * cannot be proven. A future core job kind therefore cannot silently make a
350
+ * session look idle.
351
+ */
352
+ const recordIdle = (input: unknown, at = Date.now()) => {
353
+ if (!input || typeof input !== "object" || Array.isArray(input)) return;
354
+ const value = input as { sessionID?: unknown; background?: unknown };
355
+ const id = normalizeSessionID(value.sessionID);
356
+ if (!id || !Array.isArray(value.background)) return;
357
+ if (deletedAt.has(id) || isDeletedAtOrAfter(id, at)) return;
358
+ const parentState = stateFor(id);
359
+ if (at < parentState.snapshotAt) return;
360
+
361
+ const grouped = new Map<string, ParsedIdleItem[]>();
362
+ const invalidOwners = new Set<string>();
363
+ let ownerUnknown = false;
364
+ for (const raw of value.background) {
365
+ const parsed = parseIdleItem(raw);
366
+ if (!parsed.ok) {
367
+ if (parsed.owner && !deletedAt.has(parsed.owner)) {
368
+ invalidOwners.add(parsed.owner);
369
+ } else if (!parsed.owner) {
370
+ ownerUnknown = true;
371
+ }
372
+ continue;
373
+ }
374
+ // A tombstoned session cannot own or be the child of a live job, even
375
+ // when a stale snapshot arrives with a later local timestamp.
376
+ if (deletedAt.has(parsed.item.owner)) continue;
377
+ if (
378
+ parsed.item.kind === BACKGROUND_JOB_KIND.subagent &&
379
+ deletedAt.has(parsed.item.key)
380
+ ) {
381
+ continue;
382
+ }
383
+ const items = grouped.get(parsed.item.owner) ?? [];
384
+ items.push(parsed.item);
385
+ grouped.set(parsed.item.owner, items);
386
+ }
387
+
388
+ if (ownerUnknown) {
389
+ // The snapshot cannot prove that any job ended. Preserve every known job
390
+ // and mark the idle session's subtree state unknown.
391
+ const owners = new Set<string>([
392
+ id,
393
+ ...parentState.snapshotOwners,
394
+ ...grouped.keys(),
395
+ ...invalidOwners,
396
+ ]);
397
+ for (const owner of owners) {
398
+ if (deletedAt.has(owner) || isDeletedAtOrAfter(owner, at)) continue;
399
+ const state = stateFor(owner);
400
+ if (at < state.snapshotAt) continue;
401
+ state.snapshotAt = at;
402
+ markUnknown(state, at);
403
+ }
404
+ for (const [owner, items] of grouped) {
405
+ if (deletedAt.has(owner) || isDeletedAtOrAfter(owner, at)) continue;
406
+ const state = stateFor(owner);
407
+ if (at < state.snapshotAt) continue;
408
+ for (const item of items) addJob(state, item.kind, item.key, at);
409
+ }
410
+ const nextOwners = new Set<string>([
411
+ ...parentState.snapshotOwners,
412
+ ...grouped.keys(),
413
+ ...invalidOwners,
414
+ ]);
415
+ nextOwners.delete(id);
416
+ parentState.snapshotOwners = nextOwners;
417
+ trimSet(parentState.snapshotOwners, MAX_BACKGROUND_SESSIONS);
418
+ return;
419
+ }
420
+
421
+ const nextOwners = new Set<string>([...grouped.keys(), ...invalidOwners]);
422
+ nextOwners.delete(id);
423
+ // The hook is authoritative for the whole subtree. Clear descendant owners
424
+ // that disappeared from the snapshot unless their own newer snapshot wins.
425
+ for (const owner of parentState.snapshotOwners) {
426
+ if (nextOwners.has(owner) || isDeletedAtOrAfter(owner, at)) continue;
427
+ const ownerState = states.get(owner);
428
+ if (!ownerState || at < ownerState.snapshotAt) continue;
429
+ clearAtOrBefore(ownerState, at);
430
+ ownerState.snapshotAt = at;
431
+ ownerState.hasAuthoritativeSnapshot = true;
432
+ }
433
+
434
+ const applyOwner = (
435
+ owner: string,
436
+ items: readonly ParsedIdleItem[],
437
+ trusted: boolean,
438
+ ) => {
439
+ if (deletedAt.has(owner) || isDeletedAtOrAfter(owner, at)) return;
440
+ const state = stateFor(owner);
441
+ if (at < state.snapshotAt) return;
442
+ if (trusted) {
443
+ clearAtOrBefore(state, at);
444
+ state.hasAuthoritativeSnapshot = true;
445
+ }
446
+ state.snapshotAt = at;
447
+ for (const item of items) addJob(state, item.kind, item.key, at);
448
+ if (!trusted) markUnknown(state, at);
449
+ };
450
+
451
+ // The idle session's own snapshot is authoritative even when it is empty,
452
+ // unless one of its own items could not be parsed.
453
+ applyOwner(id, grouped.get(id) ?? [], !invalidOwners.has(id));
454
+ for (const [owner, items] of grouped) {
455
+ if (owner === id) continue;
456
+ applyOwner(owner, items, !invalidOwners.has(owner));
457
+ }
458
+ for (const owner of invalidOwners) {
459
+ if (owner === id || grouped.has(owner)) continue;
460
+ applyOwner(owner, [], false);
461
+ }
462
+ parentState.snapshotOwners = nextOwners;
463
+ trimSet(parentState.snapshotOwners, MAX_BACKGROUND_SESSIONS);
464
+ };
465
+
466
+ const recordDeleted = (sessionID: string, at = Date.now()) => {
467
+ const id = normalizeSessionID(sessionID);
468
+ if (!id) return;
469
+ rememberDeleted(id, at);
470
+ states.delete(id);
471
+ for (const state of states.values()) {
472
+ state.subagent.delete(id);
473
+ state.snapshotOwners.delete(id);
474
+ }
475
+ };
476
+
477
+ const backgroundJobFor = (sessionID: string): BackgroundJobInfo | undefined => {
478
+ const state = states.get(sessionID);
479
+ if (!state) return undefined;
480
+ const kinds = BACKGROUND_JOB_KINDS.filter(
481
+ (kind) => stateJobMap(state, kind).size > 0,
482
+ );
483
+ const stateUnknown = state.unknownAt > 0;
484
+ if (kinds.length === 0 && !stateUnknown) return undefined;
485
+ return {
486
+ kinds: [...kinds],
487
+ ...(stateUnknown ? { stateUnknown: true } : {}),
488
+ };
489
+ };
490
+
491
+ const isActive = (sessionID: string): boolean =>
492
+ backgroundJobFor(sessionID) !== undefined;
493
+
494
+ /** Whether an authoritative idle snapshot has ever applied to this session. */
495
+ const hasSnapshot = (sessionID: string): boolean =>
496
+ states.get(sessionID)?.hasAuthoritativeSnapshot === true;
497
+
498
+ /**
499
+ * Structured fallback when the store has no authoritative snapshot for the
500
+ * target, such as after a restart. Running shell messages and running
501
+ * shell/image/subagent tool parts are proof of work. Code Mode scripts are
502
+ * not visible here, so they rely on the idle hook. A missing snapshot, or a
503
+ * failed or malformed read, is unknown, never idle.
504
+ */
505
+ const probe = async ({
506
+ session,
507
+ targetID,
508
+ signal,
509
+ }: BackgroundProbeInput): Promise<BackgroundProbeResult> => {
510
+ const target = normalizeSessionID(targetID);
511
+ if (!target) return { subtreeActive: false, failed: true };
512
+
513
+ const kinds = new Set<BackgroundJobKind>();
514
+ // Without an authoritative idle snapshot, a clean context is not proof
515
+ // that no job exists: the job may predate this process or have been missed.
516
+ let failed = !hasSnapshot(target);
517
+
518
+ const stored = backgroundJobFor(target);
519
+ if (stored) {
520
+ for (const kind of stored.kinds) kinds.add(kind);
521
+ if (stored.stateUnknown) failed = true;
522
+ }
523
+
524
+ const own = await readContext(session, target, signal);
525
+ if (own.failed) failed = true;
526
+ scanTargetMessages(own.messages, kinds);
527
+
528
+ // The idle snapshot names descendant owners, so known descendant jobs are
529
+ // structured evidence that the target's subtree is still active.
530
+ let subtreeActive = false;
531
+ const state = states.get(target);
532
+ if (state) {
533
+ for (const owner of state.snapshotOwners) {
534
+ if (owner === target) continue;
535
+ if (backgroundJobFor(owner) !== undefined) {
536
+ subtreeActive = true;
537
+ break;
538
+ }
539
+ }
540
+ }
541
+
542
+ const observed = BACKGROUND_JOB_KINDS.filter((kind) => kinds.has(kind));
543
+ const backgroundJob =
544
+ observed.length > 0 || failed
545
+ ? {
546
+ kinds: [...observed],
547
+ ...(failed ? { stateUnknown: true } : {}),
548
+ }
549
+ : undefined;
550
+ return { backgroundJob, subtreeActive, failed };
551
+ };
552
+
553
+ return {
554
+ recordShellStarted,
555
+ recordShellEnded,
556
+ recordIdle,
557
+ recordDeleted,
558
+ backgroundJobFor,
559
+ hasSnapshot,
560
+ isActive,
561
+ probe,
562
+ };
563
+ };
564
+
565
+ export type BackgroundJobStore = ReturnType<typeof createBackgroundJobStore>;
566
+
567
+ export interface IdleHookRegistration {
568
+ dispose: () => Promise<void>;
569
+ }
570
+
571
+ type IdleHook = (
572
+ name: string,
573
+ callback: (input: unknown) => void | Promise<void>,
574
+ ) => Promise<IdleHookRegistration>;
575
+
576
+ /**
577
+ * Register the experimental idle hook when the build exposes it. The hook is
578
+ * optional: shell events still provide partial coverage.
579
+ */
580
+ export const registerIdleHook = async (
581
+ session: unknown,
582
+ store: BackgroundJobStore,
583
+ ): Promise<IdleHookRegistration | undefined> => {
584
+ const hook = (session as { hook?: unknown }).hook;
585
+ if (typeof hook !== "function") return undefined;
586
+ try {
587
+ return await (hook as IdleHook).call(
588
+ session,
589
+ "experimental.idle",
590
+ (input: unknown) => {
591
+ try {
592
+ store.recordIdle(input);
593
+ } catch (error) {
594
+ console.error("subagent-tools: idle hook failed", error);
595
+ }
596
+ },
597
+ );
598
+ } catch (error) {
599
+ console.error("subagent-tools: idle hook unavailable", error);
600
+ return undefined;
601
+ }
602
+ };