Skip to content

Commit f018122

Browse files
committed
improvement(mothership): type the subagent span guard from the contract's span data
1 parent e552e18 commit f018122

5 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎apps/sim/lib/mothership/generated/mothership-stream-v1.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,15 @@ export interface MothershipStreamV1ToolResultPayload extends StreamToolReplay {
156156
}
157157

158158
/** A subagent lane opens (`data: {name}`) or closes (`data: {error}` when it failed). */
159+
/** A subagent lane's display title (on start) or failure (on end). */
160+
export interface MothershipStreamV1SubagentSpanData {
161+
name?: string;
162+
error?: string;
163+
}
164+
159165
export interface MothershipStreamV1SubagentSpanPayload {
160166
agent?: string;
161-
data?: unknown;
167+
data?: MothershipStreamV1SubagentSpanData;
162168
event: "start" | "end";
163169
kind: "subagent";
164170
}

‎apps/sim/lib/mothership/request/session/contract.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
MothershipStreamV1EventEnvelope,
55
MothershipStreamV1StreamRef,
66
MothershipStreamV1StreamScope,
7+
MothershipStreamV1SubagentSpanData,
78
MothershipStreamV1Trace,
89
} from '@/lib/mothership/generated/mothership-stream-v1'
910
import {
@@ -438,7 +439,8 @@ export function isSubagentSpanStreamEvent(
438439
}
439440

440441
/** What a subagent span's `data` carries: the lane `name` on start, its `error` on a failed end. */
441-
export function subagentSpanData(data: unknown): { name?: string; error?: string } {
442+
/** Reads a subagent span's untrusted `data`, keeping only non-empty string fields. */
443+
export function subagentSpanData(data: unknown): MothershipStreamV1SubagentSpanData {
442444
if (!isRecordLike(data)) return {}
443445
return {
444446
...(typeof data.name === 'string' && data.name ? { name: data.name } : {}),

‎packages/workflow-code/src/catalog/scaling.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { expectLinearGrowth } from '@sim/testing/helpers/scaling'
6-
import { describe, expect, it } from 'vitest'
6+
import { describe, it } from 'vitest'
77
import { TEST_CATALOG } from '../compile/catalog.test-helpers'
88
import { buildFieldIndex } from './surface'
99
import type { CatalogBlock, CatalogSubBlock } from './types'

‎packages/workflow-code/src/compile/scaling.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { expectLinearGrowth } from '@sim/testing/helpers/scaling'
6-
import { describe, expect, it } from 'vitest'
6+
import { describe, it } from 'vitest'
77
import { stronglyConnected } from './edges'
88

99
describe('compile scaling', () => {

‎packages/workflow-code/src/print/scaling.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { expectLinearGrowth } from '@sim/testing/helpers/scaling'
6-
import { describe, expect, it } from 'vitest'
6+
import { describe, it } from 'vitest'
77
import { compareEdges } from '../canonicalize/edges'
88
import { compileWorkflow } from '../compile'
99
import { TEST_CATALOG } from '../compile/catalog.test-helpers'

0 commit comments

Comments
 (0)