@@ -17,6 +17,7 @@ export function generateActionMethod(
1717 capabilityClassName : string ,
1818 labels : ProcessedLabel [ ] ,
1919 modePrefix : string ,
20+ teeEnabled : boolean ,
2021) : string {
2122 const capabilityIdLogic = generateCapabilityIdLogic ( labels , capabilityClassName )
2223
@@ -47,9 +48,25 @@ export function generateActionMethod(
4748 // - JSON shape -> wrapped in NoExcess so unknown keys (e.g. plain
4849 // `body` instead of `bodyString`) fail at the call boundary even
4950 // when the user lifts the request object into a variable.
50- const callSig = `<TInput>(runtime: ${ modePrefix } Runtime<unknown>, input: CapabilityInput<TInput, ${ nativeInputType } , ${ jsonInputType } >): {result: () => ${ outputType } }`
51- // Internal impl signature - widest, accepts either form.
52- const implSig = `(runtime: ${ modePrefix } Runtime<unknown>, input: ${ nativeInputType } | ${ jsonInputType } ): {result: () => ${ outputType } }`
51+ const basicSig = `<TInput>(runtime: ${ modePrefix } Runtime<unknown>, input: CapabilityInput<TInput, ${ nativeInputType } , ${ jsonInputType } >): {result: () => ${ outputType } }`
52+
53+ const callSig = teeEnabled
54+ ? basicSig . replace (
55+ `${ modePrefix } Runtime<unknown>` ,
56+ `${ modePrefix } Runtime<unknown> | TeeRuntime<unknown>` ,
57+ )
58+ : basicSig
59+
60+ const teeSig = basicSig . replace ( `${ modePrefix } Runtime<unknown>` , `TeeRuntime<unknown>` )
61+
62+ var nameAndPublicSigs = teeEnabled
63+ ? `${ methodName } ${ teeSig } \n${ methodName } ${ basicSig } ;\n${ methodName } ${ callSig } ;`
64+ : `${ methodName } ${ callSig } ;`
65+
66+ // Internal impl signature - widest, accepts either form (and either runtime when TEE is enabled).
67+ const implSig = `(runtime: ${ modePrefix } Runtime<unknown>${
68+ teeEnabled ? ' | TeeRuntime<unknown>' : ''
69+ } , input: ${ nativeInputType } | ${ jsonInputType } ): {result: () => ${ outputType } }`
5370 const callSigAndBody = `${ implSig } {
5471 // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
5572 let payload: ${ method . input . name }
@@ -113,7 +130,7 @@ export function generateActionMethod(
113130 : UnwrapOptions<TOutput>,
114131 ): (...args: TArgs) => { result: () => TOutput }`
115132 return `
116- ${ methodName } ${ callSig }
133+ ${ nameAndPublicSigs }
117134 ${ methodName } ${ sugarSig }
118135 ${ methodName } (...args: unknown[]): unknown {
119136 // Check if this is the sugar syntax overload (has function parameter)
@@ -122,7 +139,7 @@ export function generateActionMethod(
122139 return this.${ methodName } SugarHelper(runtime, fn, consensusAggregation, unwrapOptions)
123140 }
124141 // Otherwise, this is the basic call overload
125- const [runtime, input] = args as [${ modePrefix } Runtime<unknown>, ${ inputTypes . join ( ' | ' ) } ]
142+ const [runtime, input] = args as [${ teeEnabled ? ` ${ modePrefix } Runtime<unknown> | TeeRuntime<unknown>` : ` ${ modePrefix } Runtime<unknown>` } , ${ inputTypes . join ( ' | ' ) } ]
126143 return this.${ methodName } CallHelper(runtime, input)
127144 }
128145 private ${ methodName } CallHelper${ callSigAndBody }
@@ -134,7 +151,13 @@ export function generateActionMethod(
134151 return runtime.runInNodeMode(wrappedFn, consensusAggregation, unwrapOptions)
135152 }`
136153 }
154+
155+ // For DON mode: emit tee + basic overload declarations, then the implementation with its name.
156+ // nameAndPublicSigs is designed for Node mode's dispatcher pattern and must not be reused here.
157+ const donOverloads = teeEnabled
158+ ? `${ methodName } ${ teeSig } \n ${ methodName } ${ basicSig } \n `
159+ : `${ methodName } ${ callSig } \n `
160+
137161 return `
138- ${ methodName } ${ callSig }
139- ${ methodName } ${ callSigAndBody } `
162+ ${ donOverloads } ${ methodName } ${ callSigAndBody } `
140163}
0 commit comments